Question by
immanox21 · Mar 06 at 04:19 PM ·
c#scripting problemunity 2dscripting beginnerscore system
I have no Idea why my highscore Script isn't working ...
When ever I call ScoreUp
method it is automatically sets high score as score. Like there is no if
state.
Can you explain please explain why this isn't working and how can I make it work?
public void ScoreUP ()
{
Score += 1;
if (Score > PlayerPrefs.GetInt("HighScore", 0))
{
PlayerPrefs.SetInt("HighScore", Score);
PlayerPrefs.Save();
Debug.Log("HighScore Set");
}
}
void Update ()
{
scoreText.text = "Score : " + Score;
if (Input.GetKeyDown(KeyCode.P))
{
PlayerPrefs.DeleteAll();
Debug.Log("DeletedAll");
}
}
Comment