Question by
ABcodes · Oct 30, 2017 at 05:20 PM ·
timerscorescore systemhighscoreshighscore
Hey i am trying to add a time score system and time high score system need help.
how do i add timer for score and the highest time the timer reached as my high score? this is what i have tried but i am getting errors anyone want to help?
public class Timer : MonoBehaviour { public Text timertext; public Text highscore;
private float starttime;
// Use this for initialization
void Start () {
starttime = Time.time;
highscore = PlayerPrefs.GetFloat("HighScore", 0).ToString; }
// Update is called once per frame
void Update () {
float t = Time.time - starttime;
string minutes = ((int)t / 60).ToString();
string seconds = (t % 60).ToString("f2");
timertext.text = minutes + ":" + seconds;
PlayerPrefs.SetFloat("Highscore", timertext.text);
}
}
Comment