Countdown not counting down

Hi

I’m relatively new to scripting and I made this script so that when 4 players (1 at the moment for testing) enter an area a countdown starts. The problem is that it isn’t counting down. Can someone please help me by making it count! Also when it gets to 0 how do I get the player to quit the scene? Thanks.

var playersAtEndPoint = 0;

var guiskin : GUISkin;

var timeTotal = 1800;

var timeUntilEnd = timeTotal / 60;



function OnTriggerEnter (Player : Collider){

	playersAtEndPoint ++;

}	

	

function OnTriggerExit (Player : Collider){

	playersAtEndPoint --;

}

	

function Update (){



	if (playersAtEndPoint == 1){

		timeTotal = timeTotal - Time.deltaTime;	

	}

	

	if (playersAtEndPoint == 0){

		timeTotal = 1800;

	}

	

}



function OnGUI(){



	GUI.backgroundColor = Color.black;

	GUI.contentColor = Color.white;

	

	GUI.skin = guiskin;

  	GUI.Label(Rect(1,1,100,100),playersAtEndPoint.ToString());

  	GUI.Label(Rect(8,8,100,100),"/4");

  	

  	if (playersAtEndPoint == 1){

  		GUI.Label(Rect(1,30,100,100),"Time left:" + timeUntilEnd.ToString());

	}

}

Copy the calculation

var timeUntilEnd = timeTotal / 60;

to the end of your script, so that the last lines read:

if (playersAtEndPoint == 1){
  timeUntilEnd = timeTotal / 60;
  GUI.Label(Rect(1,30,100,100),"Time left:" + timeUntilEnd.ToString());
}

Doing the math outside the function makes it getting calculated only once, before any function is processed.