high scores scene

I'm working on a game in which the score is the amount of time the player is alive. So far I am using PlayerPrefs to save the score with this script: EDIT:

private var alive = true;
function OnCollisionEnter(collision : Collision) {

if(collision.gameObject.tag == "blocks")
{
    Time.timeScale = 0.000001;
audio.Pause ();
Invoke("thescore",0);
alive = false;
}
}
function thescore () {
var score : float = Time.timeSinceLevelLoad;

if( score > PlayerPrefs.GetFloat("Score1") ){
PlayerPrefs.SetFloat( "Score5", PlayerPrefs.GetFloat("Score4") );
PlayerPrefs.SetFloat( "Score4", PlayerPrefs.GetFloat("Score3") );
PlayerPrefs.SetFloat( "Score3", PlayerPrefs.GetFloat("Score2") );
PlayerPrefs.SetFloat( "Score2", PlayerPrefs.GetFloat("Score1") );
PlayerPrefs.SetFloat("Score1", score);
}
else if( score > PlayerPrefs.GetFloat("Score2") ){
PlayerPrefs.SetFloat( "Score5", PlayerPrefs.GetFloat("Score4") );
PlayerPrefs.SetFloat( "Score4", PlayerPrefs.GetFloat("Score3") );
PlayerPrefs.SetFloat( "Score3", PlayerPrefs.GetFloat("Score2") );
PlayerPrefs.SetFloat("Score2", score);
}
else if( score > PlayerPrefs.GetFloat("Score3") ){
PlayerPrefs.SetFloat( "Score5", PlayerPrefs.GetFloat("Score4") );
PlayerPrefs.SetFloat( "Score4", PlayerPrefs.GetFloat("Score3") );
PlayerPrefs.SetFloat("Score3", score);
}
else if( score > PlayerPrefs.GetFloat("Score4") ){
PlayerPrefs.SetFloat( "Score5", PlayerPrefs.GetFloat("Score4") );
PlayerPrefs.SetFloat("Score4", score);
}
else if( score > PlayerPrefs.GetFloat("Score5") ){
PlayerPrefs.SetFloat("Score5", score);
}
}

Here's an example of the new High score script that is attached to one of my guitexts in the high score scene: function Start () { guiText.text = (PlayerPrefs.GetFloat("score1")).ToString (); }

My new problem is that the high scores won't update, but instead stay at zero all the time.

Couple things:

Your going to need 5 PlayerPrefs, for the top 5 scores. I'll call them score1, score2, score3, and so on.

Second, you'll want to store them in PlayerPrefs as floats, instead of strings, and just do the .ToString() for you GUI after you retrieve them for the high score scene (that way, you can actually do math comparisons with them).

Then you'll probably want to do something like this (EDIT: after Ej's comment I realized you have to shift all the scores down one, from the bottom up, if you are overwriting a score [unless its score 5, because theres no score 6 to shift it to, so it just gets dumped] ):

var score : float = Time.timeSinceLevelLoad;

if( score > PlayerPrefs.GetFloat("Score1") ){
    PlayerPrefs.SetFloat( "Score5", PlayerPrefs.GetFloat("Score4") );
    PlayerPrefs.SetFloat( "Score4", PlayerPrefs.GetFloat("Score3") );
    PlayerPrefs.SetFloat( "Score3", PlayerPrefs.GetFloat("Score2") );
    PlayerPrefs.SetFloat( "Score2", PlayerPrefs.GetFloat("Score1") );
    PlayerPrefs.SetFloat("Score1", score);
}
else if( score > PlayerPrefs.GetFloat("Score2") ){
    PlayerPrefs.SetFloat( "Score5", PlayerPrefs.GetFloat("Score4") );
    PlayerPrefs.SetFloat( "Score4", PlayerPrefs.GetFloat("Score3") );
    PlayerPrefs.SetFloat( "Score3", PlayerPrefs.GetFloat("Score2") );
    PlayerPrefs.SetFloat("Score2", score);
}
else if( score > PlayerPrefs.GetFloat("Score3") ){
    PlayerPrefs.SetFloat( "Score5", PlayerPrefs.GetFloat("Score4") );
    PlayerPrefs.SetFloat( "Score4", PlayerPrefs.GetFloat("Score3") );
    PlayerPrefs.SetFloat("Score3", score);
}
else if( score > PlayerPrefs.GetFloat("Score4") ){
    PlayerPrefs.SetFloat( "Score5", PlayerPrefs.GetFloat("Score4") );
    PlayerPrefs.SetFloat("Score4", score);
}
else if( score > PlayerPrefs.GetFloat("Score5") ){
    PlayerPrefs.SetFloat("Score5", score);
}

hi i already do that script above but when my player finish all stage all score from 1 to 5 is same as high score, but when i game over the socre is normal… i dunno whats wrong with the script