I have a score and high score script that doesn’t seem to be working there are no errors but the high score doesn’t update when the player dies.
CODE
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ScoreOnEnd : MonoBehaviour
{
public static ScoreOnEnd End;
public Text countText;
private int count;
public Text HighScore;
private int Highcount;
public GameObject Player;
void Start ()
{
End = this;
countText.gameObject.SetActive(false);
count = 0;
SetCountText ();
HighScore.gameObject.SetActive(false);
Highcount = 0;
SetHighScore ();
Highcount = PlayerPrefs.GetInt ("HighScore1", 0);
}
void update () {
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.tag == "Coin") {
count = count + 1;
SetCountText ();
} else if (col.gameObject.tag == "Enemy") {
countText.gameObject.SetActive(true);
HighScore.gameObject.SetActive(true);
}
}
void SetCountText ()
{
countText.text = " " + count.ToString ();
}
void SetHighScore ()
{
HighScore.text = Highcount.ToString ();
}
public void CheckHighScore(){
if (count > Highcount) {
PlayerPrefs.SetInt("HighScore1", count);
}
}
}