game loads but quit in 1 second after adding a timer count down script

I would like the game to quit or restart after the timer counts down to 0

here is the code I used .

the countdown works in the play mode but after building a game it quits in the first second while there is 60 second on the counter . any ideas ?

thanks in advance

Ruck

#pragma strict

var timer : float = 60.0;

function Update()
{
timer -= Time.deltaTime;

if(timer <= 0)
{
timer = 0;
Application.Quit();
}
}

function OnGUI()
{
GUI.Box(new Rect(10, 10, 50, 20), “” + timer.ToString(“0”));
}

timer is public
Have you changed the value in the inspector (it will override the = 60f )

yes I changed it to a few different numbers to test but they all quit after the game loads , it something to do with this part of the script , its is not wait until 0 to do the next part of the script .

the script runs but does the quit straight away , i tested it with a print statement and it prints log and it put it up straight away .

if(timer <= 0)
{
timer = 0;
Application.Quit();
}

PS it a java script not C+

I will try we loadlevel to try to get that to work