One-time integer variable

Hi, I’m trying to make an integer value that changes once when the player first starts the game, and doesn’t change again, similar to Undertale’s “fun” value. Can anyone help me with this?

public class STARTGAMEVALUE : MonoBehaviour
{
    public int SGV;
    // Start is called before the first frame update
    void Start()
    {
        if (SGV == 0)
        {
            SGV = UnityEngine.Random.Range(1, 100);
            PlayerPrefs.SetInt("StartValue", SGV);
        }
        else
        {
            SGV = PlayerPrefs.GetInt("StartValue", SGV);
        }
        DontDestroyOnLoad(transform.gameObject);
    }
}

You would need to check if it already exists, i.e.

public class STARTGAMEVALUE : MonoBehaviour
{
    public int SGV;
    // Start is called before the first frame update
    void Start()
    {
        //This will get SGV if it has been set before, otherwise it will return a default value (in this case, 0)
        SGV = PlayerPrefs.GetInt ("StartValue", 0);
        if (SGV == 0)
        {
            SGV = UnityEngine.Random.Range(1, 100);
            PlayerPrefs.SetInt("StartValue", SGV);
        }
        DontDestroyOnLoad(transform.gameObject);
    }
}