- Home /
Saving highscore problem
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");
}
Answer by OrbitSoft · Feb 15, 2014 at 02:01 PM
Add ": int" to score or set it to 0, if you don't specify the computer won't know if its an int.
var score : int;
or
var score = 0;
Thank you so much. After working so hard, you really saved my week.
Your answer
![](https://koobas.hobune.stream/wayback/20220613133604im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GUITime and Score issue. 0 Answers
Highscore GUI not working properly help 0 Answers
High Score on Mobile 1 Answer
Using if/else statements in GUI 1 Answer