- Home /
Question by
aidangig56 · Oct 10, 2014 at 09:32 AM ·
functionplayerprefshighscore
How to set a numerical getint() and display it...
I am trying to make highscore and I am using player prefs. If the score is greater than the high_score than override score to new highscore and display it. But it doesn't work.
function Update()
{
highscoretext.text = (PlayerPrefs.GetInt("Highscore")).ToString ();
if (score > high_score) {
score = high_score;
PlayerPrefs.SetInt("Highscore", high_score);
}
Comment
Answer by bubzy · Oct 10, 2014 at 09:35 AM
you are saying
"if the score is greater than the high score, set the score to be equal in value to the high score"
you need to say
"if the score is greater than the high score, set the high score to be equal in value to the score"
like
if(score>high_score)
{
high_score = score;
PlayerPrefs.SetInt("Highscore",high_score);
}