Score Counter
I've made this script to save the Best Score:
public Text highScore; public Transform player; // Use this for initialization void Start () { highScore.text = PlayerPrefs.GetInt("HighScore", 0).ToString(); } // Update is called once per frame public void high () { int number = Mathf.RoundToInt(player.position.z); if (number > PlayerPrefs.GetInt("HighScore", 0)) { PlayerPrefs.SetInt("HighScore", number); highScore.text = number.ToString(); } } }
The problem is that the BestScore text and the Player ( int number = Mathf.RoundToInt(player.position.z) are in 2 different scenes, and I need the (player.position.z) from the scene 2
Your answer
![](https://koobas.hobune.stream/wayback/20220612145625im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
I can't figure out why my score doesn't save/increase 0 Answers
What's wrong with my scorescript? 0 Answers
A way to tell the player what they scored in the next scene 1 Answer
score system failure 2 Answers
How to add a score in unity? 0 Answers