Question by
WeirdWeirdo56 · Nov 13, 2021 at 09:28 AM ·
texttimerhighscore
My highscore is not working
Hi, I recently made a highscore script. But when I get a worse time than earlier my text just registers that as the high score. Help would be appreciated
float highscore;
public Text highscoreText;
// Start is called before the first frame update
void Awake()
{
highscore = PlayerPrefs.GetInt("highscore");
}
void Start()
{
highscoreText.text = "highscore: " + highscore.ToString();
}
// Update is called once per frame
void Update()
{
if (Timer.currentTime > highscore)
{
highscore = Timer.currentTime;
PlayerPrefs.SetFloat("highscore", highscore);
PlayerPrefs.Save();
highscoreText.text = highscore.ToString();
}
}
Comment