Hello everyone!
I am currently creating a game where the score is passed time. When the player dies a restart panel is shown and the timer no longer updates. But my highscore is not working and I don’t know why.
void Start()
{
HS.text = PlayerPrefs.GetFloat("HighScore").ToString();
}
void Update()
{
if (restartPanel.activeInHierarchy == true)
{
if (timeLeft > PlayerPrefs.GetFloat("Highscore", 0))
{
PlayerPrefs.SetFloat("Highscore", timeLeft);
HS.text = timeLeft.ToString("0");
}
}
if (restartPanel.activeInHierarchy == false)
{
timeLeft += Time.deltaTime;
startText.text = (timeLeft).ToString("0");
}
}