Basic Health Script, Help

Where am I going wrong? So far I have this:

public var playerhealth : int;

function Start () {
playerhealth = 100;
}

function Update () {
UI.Text("Health: ",playerhealth);
}

You need to pass a GameObject in and use GetComponent() to reference the Text Component on the Canvas with .text

Assuming the script is attached on the text gameobject under Canvas->text
If not you will need to tag the gameobject and reference it with
ref = GameObject.FindGameObjectWithTag(“taghere”).GetComponent();
eg.

var ref : GameObject;

ref = GetComponent();

ref.text = "Health: " + playerHealth.ToString();

Hello,

Use below given code like this,

guiText.text = "Health: " + playerhealth;

Hope help.

Thanks

Ram