High Score not working

Ok so, I’m a complete beginner making a game for school project. All I’ve done is followed tutorials. But with the different tutorials obviously some changes need to be made so you can incorporate other stuff from other tutorials in. Well, I was following a video on how to make score as well as high score, but the thing is my Game Over screen is in a completely different scene, with that in mind I tried to use playerprefs, now I can display my score on the game over screen but for some reason my High score doesn’t change and I’ve tried what ever I could using ChatGPT, other videos etc-

I made 3 scripts basically, score manager, score handler, and saving score:
Here they are in that order:

using UnityEngine;
using TMPro;
public class ScoreManager : MonoBehaviour
{
    public TextMeshProUGUI scoreValueText;
    public float scoreValue = 0f;
    public float pointIncreasedPerSecond = 1f;
    public TMP_Text highScoreText;

    void FixedUpdate()
    {

        scoreValueText.text = ((int)scoreValue).ToString();
        scoreValue += pointIncreasedPerSecond * Time.fixedDeltaTime;

    }
}
using UnityEngine;
using TMPro;
using TMPro.Examples;

public class ScoreHandler : MonoBehaviour
{
    public TMP_Text scoreValue;
    public TMP_Text highscore;

    private TextMeshProUGUI scoreValueText;
    private TextMeshProUGUI highscoreText;

    void Start()
    {
      
        scoreValueText = scoreValue.GetComponent<TextMeshProUGUI>();
        highscoreText = highscore.GetComponent<TextMeshProUGUI>();

        scoreValueText.text = PlayerPrefs.GetString("scoreValue", "0").ToString();

        int scorevalue = PlayerPrefs.GetInt("scoreValue", 0);
        int highscores = PlayerPrefs.GetInt("highscore", 0);
        if (scorevalue > highscores)
        {
            PlayerPrefs.SetInt("highscore", scorevalue);
            highscore = scoreValue;
            highscoreText.text = PlayerPrefs.GetInt("highscore", 0).ToString();
        }
    }

}
using UnityEngine;
using TMPro;

public class Savingscore : MonoBehaviour
{
    public TMP_Text scoreValue;
    public TextMeshProUGUI scoreValueText;

    private void Start()
    {
        PlayerPrefs.SetString("scoreValue", "0");
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Obstacle")
        {
      
            int scoreValue = PlayerPrefs.GetInt("scoreValue", 0);
            PlayerPrefs.SetString("scoreValue", scoreValueText.text);
            PlayerPrefs.SetString("highscore", scoreValueText.text);

            PlayerPrefs.Save();
        }
    }

}

There are 2 scenes, Start Game (where you play) and End Screen (when you die), the score manager is in the 1st scene and the saving score is within the player/character while the score handler is in the second scene…
Can someone please help me out with where I’m going wrong- I have been stuck on this for 2 days straight and I’m actually going to go mad…

Sounds like you wrote a bug… and that means… time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

ALSO… rather than sprinkling typo-prone text strings all over creation…

Here’s an example of simple persistent loading/saving values using PlayerPrefs:

Useful for a relatively small number of simple values.

If you just want to use my best-score or best-time solution, here it is:

Tracking simple high score / low time single-entry leaderboard:

For the highest score: Unity High score tracking - Pastebin.com

Usage:

TheBest.RecordScoreIfHigher( lastGamePlayScore);

For the lowest time: Unity best time tracking - Pastebin.com

Usage:

TheBest.RecordTimeIfLower( lastGamePlayTime);

To retrieve the best score or time, use one of these:

int bestScore = TheBest.BestScore;

float bestTime = TheBest.BestTime;

Full usage example: