My player character health bar not reduced by enemy attack

kay , so basicaly my problem is when enemy attack , it`s not affect my player , which is weird , here my script for enemy

bool CanAttack(){
	if(attackOnCooldown) return false;
	return true;
}

void Die(){
	dead = true;
	DropLoot();
	foreach(GameObject go in players){
		go.GetComponent<PlayerController>().SetExperience(expGranted/players.Length);
	}
	anim.SetInteger("Condition", 4);
	GameObject.Destroy(this.gameObject, 5);
}

IEnumerator AttackRoutine(){
	int previousState = anim.GetInteger("Condition");
	StartCoroutine(AttackCooldown());
	anim.SetInteger("Condition", 2);
	yield return new WaitForSeconds(0.1f);
	anim.SetInteger("Condition", previousState);
}

IEnumerator AttackCooldown(){
	attackOnCooldown = true;
	yield return new WaitForSeconds(1/attackSpeed);
	attackOnCooldown = false;
}

IEnumerator FindPlayerInRange(){
	while(!dead){
		yield return new WaitForSeconds(0.1f);
		
		if(targetPlayer && Vector3.Distance(transform.position, targetPlayer.position) < visionRange){
			if(Vector3.Distance(transform.position, targetPlayer.position) <= attackRange){
				if(CanAttack())StartCoroutine(AttackRoutine());
			}
			continue;
		} 

		else{
			bool foundTarget = false;
			foreach(var p in players){
				if(Vector3.Distance(transform.position, p.transform.position) < visionRange){
					followTarget.enabled = true;
					targetPlayer = p.transform;
					followTarget.target = p.transform;
					anim.SetInteger("Condition", 1);
					foundTarget = true;
					break;
				}
			}
			if(!foundTarget){
				targetPlayer = null;
				followTarget.enabled = false;
				followTarget.target = null;
				anim.SetInteger("Condition", 0);
			}
		}
	}

	followTarget.enabled = false;
}

}

and here my player script

float totalHealth = 30;
float currentHealth = 30;
bool dead;

	SetHealth(totalHealth);

public void GetHit(float damage){
	if(dead)return;
	anim.SetInteger("Condition", 3);
	SetHealth(currentHealth - damage);
	GetIncapacitated(0.2f);
}

void SetHealth(float health){
	if(health > totalHealth) currentHealth = totalHealth;
	else if(health <= 0){
		Die();
		currentHealth = 0;
	} 
	else currentHealth = health;
	healthBar.Find("Fill").GetComponent<Image>().fillAmount = currentHealth / totalHealth;
	healthBar.Find("Text").GetComponent<Text>().text = currentHealth + "/" + totalHealth;
}

IEnumerator GetIncapacitatedRoutine(){
	while(incapacitatedTime > 0){
		yield return new WaitForSeconds(0.1f);
		incapacitatedTime -= 0.1f;
	}
}

}
, do you know why ?

I’m reading this on my phone so the code format is a little difficult to read, but it seems like your problem starts with your damage variable declared on line six of your player script. You declare the variable via parameters of the GetHit function, but fail to assign it a value. So when you call the variable on line 10, it’s returning a value of zero.