Error with GUI and Variable

I am getting this error:

Assets/Thirst.js(10,10): BCE0023: No appropriate version of ‘UnityEngine.GUI.Label’ for the argument list ‘(System.Type, String)’ was found.

var Thirst : float = 500 ;
 
function Update ( ){
 //subtracts from thirst every second
   Thirst -= 1 * Time.deltaTime ;
}


//displays variable thirst
GUI.Label( Rect, "Thirst:  + Thirst + " ); 

All help is appreciated!

void OnGUI()
{
GUI.Label(new Rect(0,0,200,20),"Thirst : " + Thirst );
}

although I find capitalised variables yucky :slight_smile:

I see a couple problems but you may just not have posted the entire script

  1. Rect isn’t a declared variable so the label doesn’t have coordinates and size.
  2. You string "Thirst: + Thirst + " should be "Thirst: " + Thirst
    So the whole line should be
    GUI.Label( Rect, "Thirst: " + Thirst);
    The error is referring the "Thirst: + Thirst + " not the Rect but it will probably be the next error you get.