How to make a GUI or HUD

I know there are tons of threads on here about making a gui but none of them seem to be working for me. I am trying to use a GUI.Label and make a "PlayerHealth" variable visible to the player as a number, not a healthbar. i.e. it shows 100 when at max and you get hit it falls down to 94. Is there any way to link a interger variable into a GUI.Label script?

thanks in advance

ok so, this is my new code

var PlayerHealthDisplay : int;

FPSWalker.PlayerHealth = PlayerHealthDisplay;

guiText.text = PlayerHealthDisplay;

but the console says "Cannot convert integer into String".

Now what?

I think what you are looking for is not GUI.Label, but a GUIText

When you have the Text in place, you can simply create a reference to it in your script, and change it's value by changing .text with your script.

So in C# just:

GUIText myText;
int myHeath = 100;
myText.text = myHealth.ToString();

Actually... Can't you just do a OnGUI script?


function OnGUI(){

On the object that contains PlayerHealth?

If you're talking about using a GUIText though, like Smorpheus said above... It would be kinda like

theGuiText.text = PlayerHealth.ToString();

As he has done so above, with theGUiText referring to the GUIText you created, and PlayerHealth being the float/int variable you created.

If you want it Updated you should keep it inside of a function Update(){}