Hey. I made this little high score script for my tetris like game. It works fine but when I restart the game the high score is gone. I was wondering how to add the score to Playerprefs?

using UnityEngine;
using System.Collections;

public class ScoreManager : MonoBehaviour {

public int currentScore=0;
public int highScore;

void Awake()
{
    if (Managers.Game.stats.highScore != 0)
    {
        highScore = Managers.Game.stats.highScore;
        Managers.UI.inGameUI.UpdateScoreUI();
    }
    else
    {
        highScore = 0;
        Managers.UI.inGameUI.UpdateScoreUI();
    }
}

public void OnScore(int scoreIncreaseAmount)
{	
	currentScore += scoreIncreaseAmount;
    CheckHighScore();
    Managers.UI.inGameUI.UpdateScoreUI();
    Managers.Game.stats.totalScore += scoreIncreaseAmount;
}

public void CheckHighScore()
{
    if (highScore < currentScore)
    {
        highScore = currentScore;
    }

}

public void ResetScore()
{
    currentScore = 0;
    highScore = Managers.Game.stats.highScore;
    Managers.UI.inGameUI.UpdateScoreUI();
}

}

Hi @ItsMelvin ,
Since your value is an integer, you can use
PlayerPrefs.SetInt("highscore",value)
to save a specific value even when the game is closed (don’t forget to compare it with the current saved highscore before updating it). (You can execute this once your game is ended)

Then at the beginning of your game, you can do
int previousScore = PlayerPrefs.GetInt('highscore')
To get the saved highscore.