Cool down timer script does not function right

Hey guys, i’m using c# in unity and basically there’s a timer

The timer starts at 0, and when it is == to 0 the player can attack. When the player does attack the timer gets == to the cooldown which is 2 seconds.

The update function then decrements it back to 0 enabling the player to attack again.
//put timer on attack
public float attackTimer;
public float coolDownCountTimer ;

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


}

// Update is called once per frame
void Update () {

	attackTimer -= Time.deltaTime;
	if(attackTimer < 0)
	{
		attackTimer =0;
	}
	if(attackTimer>0)
	{
		attackTimer = 0;}

	Debug.Log(attackTimer);
	//when player clicks we attack, we look for mouse input
	if(Input.GetMouseButtonDown(0))
	{
		if(attackTimer == 0)
		{

			//Debug.Log ("Attack");
			Attack(pDamage);
			//eveyr time we attack, reset attack timer to cool down 
			attackTimer = coolDownCountTimer;
		}

	}

Right now your attack timer is always set to 0 because you said if your attack timer is less than zero, set it to zero. And if your attack timer is greater than zero, set it to zero. I’m also not sure what the difference between the attack timer and the cooldown timer is.

I think what you need to down is have a boolean for attack = true/false. Then you need to have one timer that counts down from 2 seconds. When that timer is greater than 0, the attack boolean is set to false. When that timer is equal to 0, the attack boolean is true. Once the player attacks, the timer is reset, counting down from 2 seconds. I don’t have any code for you, but there are pleanty of tutorials out there for you. You could also try this method