Cannot implicitly convert type 'int' to 'bool'

I am getting this error when I try to say that my health is at 0 to load the level of my main menu

public static int Health;

void update ()
{
//continuously damage player
DamagePlayer(1);
if(Health <=0);
Health =0;
destroy (gameObject);
Application.LoadLevel("scene1");
}

The ; after your if statement should
be replaced with a {

Don’t know if
this will solve the problem though.

replace

  • ;

with

  • {

Please format your code with appropriate spacing and line breaks following some sort of standard, e.g.:

public static int Health;

void update () { 
	//continuously damage player 
	DamagePlayer(1); 
	
	if(Health <= 0){ 
		Health = 0; 
		Destroy (gameObject); 
		Application.LoadLevel("scene1"); 
	}
}

After doing that, if the error persists, please indicate exactly which line the error is occurring on.

Another question, unrelated to the issue, do you know why are you declaring Health as a static? This would ordinarily be used to ensure that Health is the same value for all instances of your class.

This is totally broken. Go back to the learn section, do the scripting tutorials over, and start again.

Here is a script for you that will compile, meets convention, and does something useful.

 public int health;
 
 void Update ()
 {
     health -= Time.deltaTime;
     if(health <=0){
         health =0;
         Destroy (gameObject);
         Application.LoadLevel("scene1");
     }
 }