Get variable from another object

I’ve been looking around for information on this, but the reference keep confusing me.

All I want to do is set my GUI to display the health of my player.

So I have an object named PlayerModel,with a script named Health, with a variable named health.

I then have an empty gameobject I named GUI, and it needs to set var health to… the player’s health!

I tried:

private var health =;

function OnGUI () 


	GUILayout.Label("HP:" + health);

but that reports 100 constant.
I’m guessing the key is to refer to the PlayerModel with GetComponent somehow?

The problem is, that the health variable is set to the player’s health at the start and never modified. You have to either update the health variable periodically, or simply display the variable directly:

function onGUI() {
    GUILayout.Label("HP: " +;