variable doesn't change

the actual script is 500+ lines long so here are some parts
this is the function for getting hit with a fireball

function FireballHit () {
health -= laserDamage * damageMultiplier * 2.5; //damage
if(blocking == 0){ //if not blocking
Instantiate(laserHitSound,transform.position,transform.rotation); //play a sound
hit = 1; //character is hit
transform.Rotate(Vector3.right * -20); //rotate backwards to make it look better
Destroy(shownMesh);// destroy the current mesh
shownMesh = Instantiate(hitMesh,transform.position,transform.rotation); // create a
//different mesh
Invoke("Unhit",3);//stop being hit (hit = 0;)
}
}

all the attacks have if(hit == 0){ at the start
when the character is hit, hit doesn’t change from 0, does anyone know the problem?

put a print(hit); straight after your hit command. and also print(“hit line 20”); etc every time ; and copy those 2 lines about 10 times down the code, so that when you play you see what happens to hit, where it changes and changes back. i had an error like that and in the end i had left a variable change outside of the loop i thought it was in.