So I could succesfully implement a different method from this guy: https://answers.unity.com/questions/1378780/save-timer-highscore-1.html Thanks everyone for your patience and help! Currently this is able to save my highscore if I hit the restart button to reload my scene. If you stop playing and hit the play again however it resets to zero, so there's a chance this isn't what others are looking for.
Modified code:
public TextMeshProUGUI scoreText;
public TextMeshProUGUI highScore;
float score;
// Start is called before the first frame update
void Start()
{
StartGame();
highScore.text = PlayerPrefs.GetFloat("HighScore", 0).ToString();
}
// Update is called once per frame
void Update()
{
if (isPlayerAlive == true)
{
score += Time.deltaTime * scoreMulti;
scoreText.text = score.ToString("Score: 0");
if (score > PlayerPrefs.GetFloat("HighScore", 0))
{
PlayerPrefs.SetFloat("HighScore", score);
highScore.text = score.ToString();
}
}
}