A object that takes away an enemies health.

I have two scripts, one is attached to the enemy called enemyhealth, and a script attached to the projectile called changehealth. This is the changehealth script:

function OnCollisionEnter (myCollision : Collision) {
 if(myCollision.gameObject.name == "enemy"){
  var health : enemyhealth = myCollision.gameObject.GetComponent(enemyhealth);
   health.HP = HP - 5;
 }
}

and this is the enemyhealth script:

var HP : int = 5;

function Update () {

	if(HP < 0) {
		DestroyObject (gameObject);
	}
}

The only problem is that the changehealth script cannot access the HP value of the enemyhealth script. I can’t figure out how to fix it. What do I do?

figured what went wrong.

function OnCollisionEnter (myCollision : Collision) {
 if(myCollision.gameObject.name == "enemy"){
  var health : enemyhealth = myCollision.gameObject.GetComponent(enemyhealth);
   health.HP = health.HP - 5;
 }
}

or you can type:

health.HP -= 5;

and instead of making a variable you can do this:

myCollision.gameObject.GetComponent(enemyhealth).health.HP -= 5;