Usually I can stamp out these errors pretty quickly but I can’t fix this one and it’s driving me mad…
I have a ‘hiscoreSave’ value that is saved in my ‘Scoring’ script using PlayerPrefs.
I am trying to display this ‘hiscoreSave’ value in a ‘StartBestScore’ Text GameObject in a different scene.
I am using the following code in a seperate script called ‘StartMenuScore’ which is attached to my MainCamera and has the 'StartBestScore’Text GameObject attached in the editor:
public Text StartBestScore;
private Scoring scoring;
void Update ()
{
print("display best score");
StartBestScore.text = "Best: " + scoring.hiscoreSave / 10 + "m";
}
When I run the scene my console just fills up with ‘object reference not set’ errors, when I double click the error it is saying this line is the error and tells me to rename hiScore to hiscoreSave which isn’t what I want to do. (hiscoreSave is the PlayerPref value)
What am I doing wrong here?