[Trouble with playerprefs] want to update highscore from scene to scene


I’m afraid without knowing almost nothing about your project, it is impossible for me to help you with this. Please share more information. Or did you solve your problem and wanted to share screenshots of your game?

you can see that my project is a block breaker game and my best score doesn’t update from scene of scene, my playerprefs save only the best score of my Level 1 and nothing else

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Hope this helps :slight_smile:

See also;

public void gameOverDesu()
gameOver = true;
points = 0;
int highscore = PlayerPrefs.GetInt(“HIGHSCORE”);
PlayerPrefs.SetInt(“HIGHSCORE”, currentScore);
highscoreText.text = currentScore.ToString();
highscoreText.text = highscore +"\n".ToString();


Unfortunately, the code is still not formatted properly, which makes it difficult to read for me. Unless I’m wrong, you save the highscore in the PlayerPrefs. To display that value in another scene, you’ll have to call PlayerPrefs.GetInt.

1 Like