Can't access a variable

My Player object contain script HealthBar, which contain a public variable currentHealth. I want to access it from another game object, but my code doesn’t work:

var player : Transform;

function Attack()
{
	player.GetComponent("player").currentHealth -= 10;
}

It should be:

player.GetComponent("HealthBar").currentHealth -= 10;

Inside GetComponent it should contain the name of your script and not the name of your player game object.