Errors that can't see!

Hi there im getting the following errors in my script:

Assets/My Scripts/Character_Controller.js(98,61): BCE0043: Unexpected token: ;.
Assets/My Scripts/Character_Controller.js(100,9): BCE0043: Unexpected token: if.
Assets/My Scripts/Character_Controller.js(98,61): BCE0043: Unexpected token: ;.

And below is my script:

function OnControllerColliderHit (hit:ControllerColliderHit);
{
	if(hit.gameObject.tag=="Health");
	{
	    HealthBar.health +=20;
	    Destroy(hit.gameObject);
	}
    
	if(hit.gameObject.tag=="SkeleSword");
	{
	    HealthBar.health -=5;
	}
    
	if(hit.gameObject.tag=="ScorpClaw" && !animation.IsPlaying"ScorpClaw"));
	{
	    HealthBar.health -=5;
	} else HealthBar.Health ==0;
    
	}
    
	if(hit.gameObject.tag=="ScorpSting" && animation.IsPlaying("Blocking"));
	{
    
	        HealthBar.health -=2;
	} else HealthBar.health -=6;
	}	

I can’t see the error myself although I know it will be a simple one but can anyone point them out to me would be a great help thanks!
GDM

You don’t need a semi colon at the end of if statements. Also some of your brackets around the else statement don’t look right. That’s where your errors are coming from. They should look like this:

if(A)
{
    //do something (don't forget semi colon at the end of code lines)
}
else if(B)
{
    //do something else (don't forget semi colon at the end of code lines)
}
else
{
    //do something else (don't forget semi colon at the end of code lines)
}

There are several errors in your code, all of them to do with ‘if / else’ syntax.

For starters, if statements must not have semicolons at the end. The point of an if-statement is to determine whether the program should enter a block of code or not (the part designated by the curly braces after the if statement), and is not in itself an expression- and as such, it should not be closed by a semicolon.

so this:

if(condition);
{
     // stuff
}

should be this:

if(condition) {
    // shenanigans
}

The other problems are to do with confusion over the ‘else’ keyword.

‘else’ is very similar to if in that it also designates entry into a block of code. It needs to be followed by curly braces, or at least a line-feed:

} else { // after an if block
    // do things
}

In your code you have a few places where you make function calls- a call like this must be formed like so:

nameOfObject.NameOfFunction(paramaters...);

So, where you have ‘animation.IsPlaying"ScorpClaw")’, it simply won’t work because you are missing the open bracket at the beginning of the paramater! It should go like this:

animation.IsPlaying("ScorpClaw")

Lastly, you must always have the exact same number of open and close brackets. In your posted code, you have 5 open braces, and 6 close braces! If you fix these problems, and more importantly understand why they happen, you’ll learn a lot about what you’re actually doing here.