Calling variables from other scripts

Ok I have followed every single question and I even looked at the manual and this is getting ridiculous. I keep trying to call my variables curHealth and maxHealth for a GUI
script from the Health script

var health : Health = GetComponent(Health);

function OnGUI()
{
GUI.Label(Rect(10,10,100,20), “Health:” + health.curHealth + “/” + health.maxHealth);
}

@script RequireComponent (Health)

I either get errors that say that variables can not be called using the GetComponent function but if I do it the way it says in the manual it will just say it needs a reference.

You cannot get the component upon the declaration of the variable (it might not be ready at that time). What you need to do is retrieve the component during the Awake phase:

@script RequireComponent (Health)

// declaration
var health : Health;

// retrieve component
function Awake()
{
    health = GetComponent(Health);
}

// use it
function OnGUI()
{
    GUI.Label(Rect(10,10,100,20), "Health:" + health.curHealth + "/" + health.maxHealth);
}

hp = GetComponent(“Health”) as Health; //do this at initialization

void OnGUI() {

GUI.Label(Rect(10,10,100,20), “Health:” + hp.curHealth + “/” + hp.maxHealth);

}