hack and slash player attack 'Cannot implicitly convert type `float' to `bool'

When I try to use this script

using UnityEngine;
using System.Collections;

public class PlayerAttack : MonoBehaviour {
public GameObject target;
public float attackTimer;
public float cooldown;

// Use this for initialization
void Start () {
	attackTimer = 0;
	cooldown = 2.0f;
}

// Update is called once per frame
void Update () {
	if(attackTimer > 0)
		attackTimer -= Time.deltaTime;
	
	if(attackTimer < 0)
		attackTimer = 0;
			
	if(Input.GetKeyUp(KeyCode.F)) {
		if(attackTimer = 0){
			Attack();
			attackTimer = cooldown;
		}	
	}
	
}

private void Attack(){
	float distance = Vector3.Distance(target.transform.position, transform.position);
	
	Vector3 dir = (target.transform.position - transform.position).normalized;
	
	float direction = Vector3.Dot(dir, transform.forward);
	
	if(distance < 2.5f){
		if(direction > 0){
			EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
			eh.AdjustCurrentHealth(-10);
					
		}
	}	
}

}

it says in the console

Assets/Scripts/PlayerAttack.cs(24,25): error CS0029: Cannot implicitly convert type float' to bool’

That’s because you’ve got a slight spelling error.

if (attackTimer = 0)

it should read

if (attackTimer == 0)

If test expect a bool value, but the result of attackTimer = 0 is a float value. Also, you probably didn’t mean to set attackTimer to 0, but rather test it.

“Cannot implicitly convert type ‘float’ to ‘bool’” is a generic error where there is a type conversion mismatch that can’t be resolved implicitly (automatically). It suggest you to do the cast explicitly (manually) to assure you that you will become aware of potential information loss in the process. In your case, there isn’t any reasonable conversion but it caught you an error anyhow.