Hey, I’m working on a game that involves a timer, and once it gets to zero it resets. I want it so it will always go back to ten, and I want the time to be saved into PlayerPrefs so it when you start the game the timer is at the same number it left off at when the game was closed. Here is my script so far:
`#pragma strict
var timevalue : int;
function Start ()
{
Repeat ();
}
function Repeat ()
{
while(true)
{
yield WaitForSeconds (1);
timeval -= 1;
PlayerPrefs.SetInt(“time”, timeval);
PlayerPrefs.Save ();
}
}
function Update ()
{
if(timevalue < 1);
{
timevalue += 10;
}
}`
I’m working using javascript (as you can tell), so please make sure you reply with javascript answers.