JavaScript Timer/Highscore Problem

I tried to make a script which would let me press a button to see the current time that has passed since the level started but it just prints 0 when i press the button. I have pressed I to stop the recording and tried in many different ways. Im a bit new to java so please be patient with me. Thanks for any help i might get.

here is my codes:

static var record : boolean;
static var currentTime : float;
static var bestTime : float;
 
function Start () {
    // Reset current time
    currentTime = 0.0;
 
    // Start record
    StartRecord();
}
 
function Update () {
    // Keep adding to currentTime if record is true
    if (record)
        currentTime += 1*Time.deltaTime;
 
    // If Player press R then run Respawn function
    if (Input.GetKeyDown(KeyCode.R))
        Respawn();
		
	// If Player press I then stop recording time
	if (Input.GetKeyDown(KeyCode.I))
		StopRecord(true);
}
 
function Respawn () {
    if (!Application.isLoadingLevel)
        Application.LoadLevel(Application.loadedLevel);
}
 
static function StartRecord () {
    record = true;
}

static function StopRecord (checkBestTime : boolean) {
    record = false;
    if (checkBestTime && currentTime<bestTime) {
        bestTime = currentTime;
        PlayerPrefs.SetFloat("Score", bestTime);
    }
}

And this:

function OnGUI () {
	if (GUI.Button (Rect (0,0,200,100), "Click for highscore")) {
		print (PlayerPrefs.GetFloat("Score"));
	}
}

your default besttime value is 0. So you will never beat your best time. You should first check in your StopRecord function if bestTime is 0 then set your bestTime to your currentTime. After that, this should work.

static function StopRecord (checkBestTime : boolean) {
    record = false;
    if (checkBestTime && (currentTime<bestTime || bestTime == 0)) {
        bestTime = currentTime;
        PlayerPrefs.SetFloat("Score", bestTime);
    }
}