Help w/ Highscores

I have a highscore system, that does save stuff, however it takes in any score. That’s probably confusing but basically, I can have a high score of 8, die, and when I get 1 score, the high score then sets itself to 1.

Does anybody know why this happens?

Of course, here’s the code:

using UnityEngine.SceneManagement;
using UnityEngine;
using UnityEngine.UI;
using System;

public class LogicScript : MonoBehaviour
{
    public int playerScore;
    public Text scoreText;
    public Text highText;
    public GameObject gameOverScreen;
    public int highScore;

    public void Awake()
    {
        highText.text = PlayerPrefs.GetInt("highScore").ToString();
    }

    [ContextMenu("Increase Score")]
    public void addScore(int scoreToAdd)
    {
        if (GameObject.Find("Bird").GetComponent<Bird_Script>().birdIsAlive==true)
            playerScore = playerScore + scoreToAdd;
            scoreText.text = playerScore.ToString();
            if (playerScore > highScore)
            {
                highScore = playerScore;
                PlayerPrefs.SetInt("highScore", highScore);
                PlayerPrefs.GetInt("highScore");
                PlayerPrefs.Save();
            }
        highText.text = PlayerPrefs.GetInt("highScore").ToString();
    }

    public void restartGame()
    {
        if (playerScore > highScore)
        {
            PlayerPrefs.SetInt("highScore", playerScore);
            PlayerPrefs.GetInt("highScore");
            PlayerPrefs.Save();
        }
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }

    public void gameOver()
    {
        gameOverScreen.SetActive(true);

    }
}

Again, can anybody help me with this?

HI there @dumbpro555. It looks like the issue here is you forgot to set highScore to the PlayerPrefs highScore. Meaning the variable highScore is set to zero by default, and you never set it to the saved high, and so playerScore will always be greater.
Hope this helps :slight_smile: .

Yup, thats what I found to, just forgot to say I solved it lol.