Hello, i am new to coding and just followed Brackey’s “how to make a video game” series. Now i am trying to add a high score in my game. I have got something working here:
using UnityEngine;
using UnityEngine.UI;
public class Dice : MonoBehaviour {
public Text score;
public Text highscore;
public Transform player;
void Start()
{
highscore.text = PlayerPrefs.GetString("Highscore");
}
void Update()
{
PlayerPrefs.SetString("Highscore", score.text);
}
}
This is probably not the best way to do this at all but now in my game it saves the high score in the correct text but it does it every time the player dies ans does not save the highest score, just the previous one. Could someone explain how I can make this work as I can’t use “<” or “>” in an if statement because my score and high score are strings. Please help!