hey guys on i have the latest highscore displayed on main menu and everytime the game end or stage is complete i use this code to check against highscore in playerprefs Code (csharp): Int latestScore = scoring.score; Int prevousScore = Playerprefs.GetInt("HighScore"); if(latestScore >= previousScore) { Playerprefs.SetInt("Highscore",latestScore); } Now the problem is that for some reason, no matter the score it updates that value so if player scored 2500 first game then played again and only scored 1000 then that 1000 will overwrite the 2500 any ideas why this is? am i missing something?
Code (csharp): Int latestScore = scoring.score; Int prevousScore = Playerprefs.GetInt("HighScore"); // ^ Upper case 'S' if (latestScore >= previousScore) { Playerprefs.SetInt("Highscore", latestScore); // ^ Lower case 's' }
i actually have that in my code i just wrote this post by hand instead of copying and pasting so that was an error on my part.
It is hard to tell without seeing the rest of the script. Put a break point at the "if" condition and see if the previous has the right value. You may also try calling PlayerPrefs.Save.
i figured it out and yes you were right i was playing around with the playerprefs and i wasnt calling the .Save() like i should have thanks alot!