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);
}
}