I'am beginner in coding. I'am trying to make a game, so when the player hits an object then adds +1 point to my score
variable. I think I've made it succesful, but I want to save this score to highScore
.
My problem is: When I restart the game than high score is again equal to score. So the high score is not saved.
Can somebody help me?
Here is my code:
public Text highScoreText;
public TextMeshProUGUI goalScore;
public int highScore;
public int score;
void start()
highScore = PlayerPrefs.GetInt("High Score", 0);
highScoreText.text = "High Score: " + highScore;
UpdateScore();
public void UpdateScore()
score ++;
goalScore.text = "Goals: " + score;
highScoreText.text = "High Score: " + highScore;
if (score > highScore)
{
highScore = score;
highScoreText.text = "High Score: " + score;
}