Expecting ) found =

I know this has been asked before, but not in this exact way. I’ve searched for a solid half hour now and haven’t found anything on this. I’m trying to get a projectile to hit the player, disappear, and deal damage to the player. I’m getting 3 errors and I’m not sure how to fix them. First is “expecting ), found ‘=’.” at line 10. Second is “Unexpected token: Player.” at line 10. And lastly, “expecting :, found ‘-=’.” at line 12. I’m sure it’s something simple… Anyways, code:

private var hitPointsDamager : HitPoints;
var damage = 10.0;

hitPointsDamager = HitPoints.hitPoints;


function OnCollisionEnter(collision : Collision)
{
	if(collision.collider.tag = "Player")
	{
	HitPoints.hitPoints -= damage;
	Destroy(gameObject);
	}
}

First up, the

if(collision.collider.tag = "Player")

bit is almost certainly wrong. It should be an == sign, which tests for equality, instead of a = sign, which assigns the right-hand-side to the left-hand-side!

Also, correct me if I’m wrong someone who actually knows javascript, but I don’t think the -= operator works in that language. Just write it out in full.

There are some other issues here- think very carefully about what you are doing with that hitPointsDamager- is it a HitPoints object, or is it a float? In one place you seem to be treating it as one, and somewhere else you are treating it as something else. Is HitPoints.hitPoints a static member? What is the hitPointsDamager actually there for?