- Home /
Question by
Cryno1000 · Jan 17, 2020 at 02:09 AM ·
playerprefsscore systemhighscores
One PlayerPref not saving
I'm having an issue where all of my playerprefs save except one. Could you guys take a look at it?
if (SceneManager.GetActiveScene().name == "zombies")
{
zombiesscore = scoreValue;
if (zombiesscore > PlayerPrefs.GetInt("zombieshighscore", zombiesscore))
{
PlayerPrefs.SetInt("zombieshighscore", zombiesscore);
highScore.text = zombiesscore.ToString();
}
}
P.S.: All of my PlayerPrefs are working in the editor, including this one. And they all work in the build EXCEPT for this one.
Comment
There's no possible way to know what's happening here just by watching the code. And the way this is written does not allow you much room for debugging. Save the value of GetInt in a variable and see what you get.
Answer by hameed-ullah-jan · Jan 17, 2020 at 06:44 AM
Remove the second parameter from this function:
PlayerPrefs.GetInt("zombieshighscore", zombiesscore)
Re-write this statement as: PlayerPrefs.GetInt("zombieshighscore")