how to get variable from collided object?

this is my code in onControllerColliderHit

“EnemiesAttack” is the name of another script

if(Hit.gameObject.tag == "enemiesAttack")
	{
		var currentAttack:GameObject = Hit.gameObject;
		var damage:int = currentAttack.GetComponent(EnemiesAttack.attackPower);
		hpPlayer = hpPlayer - damage;
		Destroy(currentAttack);
		Debug.Log(hpPlayer);
	}

and this is the code that i attached on the object i tagged “enemiesAttack”

var attackPower:int=10;

function Update () 
{
	
}

i want hp of the player to be decreased with the amount of attackPower …
i dont know what i did wrong , im new at unity and new at programming as well

plss help me :frowning: thx

I’m not sure where you’re getting your problem, but it looks like you’re not using GetComponent correctly.
It should be currentAttack.GetComponent(EnemiesAttack).attackPower.

waaahhh … thank you so muchhh …it fixed now !!! :smile: :smile: :smile: