The problem is that when you lose, the score does not stop, but continues to go until you click on restart. What l must fix?
Also, generally does not save the last score in the game, there is simply 0 there. The code : using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameControl : MonoBehaviour { public int scorePlayer; [SerializeField] public int highScore = 0; private float timer; [SerializeField] public Text txt; public Text hightxt; public bool lose; void Start() { } void Update() { hightxt.text = "High Score: " + highScore; txt.text = "Your Score: " + scorePlayer; if (lose == false) timer += 1 * Time.deltaTime; if (lose == true) { if (highScore < scorePlayer) { highScore = scorePlayer; hightxt.text = "High Score: " + highScore; } timer = 1 * Time.deltaTime; } if (timer > 1 && lose == false) { scorePlayer += 1; timer = 0; } } }