Hi guys, could you please tell me what is wrong with my script? If I set it at a normal integer like 5 it does show up in the text, but I want the highscore to show up. Probably I overlooked something again. Thanks in advance ![]()
public Text scoreText;
public Text highscoreText;
int score;
int oldHighscore;
void Start ()
{
score = 0;
oldHighscore = PlayerPrefs.GetInt("highscore", 0);
InvokeRepeating ("ScoreUpdate", 1, 0.5f);
}
void Update ()
{
scoreText.text = "Score: " + score;
highscoreText.text = "Highscore: " + PlayerPrefs.GetInt("highscore");
if (score > oldHighscore)
{
PlayerPrefs.SetInt ("highscore", score);
oldHighscore = score;
PlayerPrefs.Save ();
}
}
void ScoreUpdate ()
{
score += 1;
}
}
public Text scoreText; public Text highscoreText; int score; int highscore; void Start () { score = 0; InvokeRepeating ("ScoreUpdate", 1, 0.5f); highscore = PlayerPrefs.GetInt ("High Score"); } void Update () { scoreText.text = "Score: " + score; highscoreText.text = "Highscore: " + highscore; } void ScoreUpdate () { score += 1; if (score > highscore) { PlayerPrefs.SetInt("High Score", score); PlayerPrefs.Save (); } } I tried a different code , still does not work
– AminSB00