Im trying to save the highscore for my game but i can't figure it out!
I used mybringbacks tutorial: http://www.youtube.com/watch?v=1ZGDBuJjFbY
On how to save highscore. Its a little complicated for me, and when i write it into my script, it says:
Operator '>' cannot be used with a left hand side of type 'Object' and a right hand side of type 'int'.
What do i do wrong, and how do i fix it and make my highscore?
#pragma strict
var score;
var highscore = 0;
function Update ()
{
score = GameObject.Find("CounterGUI").GetComponent(Counter).Timer;
if (GameObject.Find("Spaceship").GetComponent(Clickmove2).die == true)
{
GetComponent(GUIText).enabled = true;
}
if(score > PlayerPrefs.GetInt("highscore"))
{
PlayerPrefs.SetInt("highscore" , score);
}
guiText.text = "Best:" + PlayerPrefs.GetInt("highscore");
}
↧