Timer ends game

I have this code but once it reaches 0 it just starts to go negative, what I want is if time ends(0) it loads my end game screen.

Any help would be appresheated thanks.

private var startTime;
private var restSeconds : int;
private var roundedRestSeconds : int;
private var displaySeconds : int;
private var displayMinutes : int;

var countDownSeconds : int;

function Awake() {
    startTime = Time.time;
}

function OnGUI () {
    //make sure that your time is based on when this script was first called
    //instead of when your game started
    var guiTime = Time.time - startTime;

    restSeconds = countDownSeconds - (guiTime);

    //display messages or whatever here -->do stuff based on your timer
    if (restSeconds == 60) {
        print ("One Minute Left");
    }
    if (restSeconds == 0) {
        print ("Time is Over");
        //do stuff here
    }

    //display the timer
    roundedRestSeconds = Mathf.CeilToInt(restSeconds);
    displaySeconds = roundedRestSeconds % 60;
    displayMinutes = roundedRestSeconds / 60; 

    text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds); 
    GUI.Label (Rect (400, 25, 100, 30), text);
    }

OnGUI is called multiple times per frame and a new frame is rendered multiple times per second, so it’s very unlikely that restSeconds will ever be exactly equal to 60 or 0. What you ought to do is check whether restSeconds <= triggeringTime. If you want to make sure the event doesn’t happen more than once, you can put in a simple boolean flag to see if it’s triggered or not. e.g.,

//your existing vars
private var oneMinuteWarningFired : bool = false;

//Your other code up to OnGUI
function OnGUI ()
{
    // Your onGUI time setting code.
    if (restSeconds <= 60 && !oneMinuteWarningFired)
    {
        print ("One minute left");
        oneMinuteWarningFired = true;
    }
    if (restSeconds <= 0)
    {
        print ("Time is Over");
    }
}

// and so on