Stop scripted GUI to appear on scene start

Hello!

I tried to let a GUI appear when a integer reaches 0. Well, it appears on the normal canvas and not when the int. is set to 0.

My Code:

#pragma strict
public var TimeLeft : int = 750;
public var style : GUIStyle;
public var Shoot : AudioSource;
function Update(){
      
      TimeLeft -= 1;
      
       if(TimeLeft<0){ 
       
       TimeLeft = 0;
       
       }
      
      if(TimeLeft == 0){
        OnGUI();
             
               if(Input.GetKey(KeyCode.E)){
                     Shoot.Play();
                     Application.LoadLevel(1);
               
               }
      }

}
function OnGUI(){

 GUI.Label ( new Rect (10f, 100f, 200f, 50f), "Press E to give up", style);

}

How can I stop it?

~C8002

OnGUI is called by Unity, so you should not be calling it in your Update method. Instead of checking if TimeLeft == 0 in your update method, move the check to your OnGUI method, and only call GUI.Label() when TimeLeft == 0. You can still check if TimeLeft == 0 in your Update method for the Input test though.

If you’re having problems with the timer hitting 0 immediately, make sure the game object that this script is attached to has a non-zero value for TimeLeft in the Inspector.