When you define your health variable do it like this
var Health1 : int ;
and set the value from the inspector, selecting the gameobject.
and i recommend you to try also putting your if code this:
if(Health1 > 1000){
Health1 = 1000;
}
if(Health1 < 0){
Health1 = 0;
}
inside a function and call it after applying damage.
and not from Update() maybe this is causing the problem too.
↧