Reference Function Trouble

`
//first script
function TakeDamage(amount : int)
{
var difference=MaxHp/amount;
if(difference<=10)
animation.CrossFadeQueued(“Heavy Damage”);
else
animation.CrossFadeQueued(“Light Damage”);
Hp-=amount;
}

//this is in a different script

function Awake()
{
var charac=GameObject.Find(“Player”);//get object.
var playerinfo=charac.GetComponent(“PlayerObj”);//get script
}

if(Input.GetButton(“Fire1”))
{
playerinfo.TakeDamage(25);
}

`

I keep getting a code that says : Unknown identifier: ‘playerinfo’. Could someone tell me what I’m doing wrong?

var playerinfo must be outside the functions, globally available to all the functions. Put it above all else

why not just use send message?

and also try this :

var charac : GameObject;
var playerinfo : PlayerObj; //your script name i think

function Awake()
{
charac=GameObject.Find(“Player”);//get object.
playerinfo=charac.GetComponent(“PlayerObj”);//get script
}

//this goes in he update
if(Input.GetButton(“Fire1”))
{
playerinfo.TakeDamage(25);
}