- Home /
score broken, score loads on new scene but then errors
Hi,
I have a game with targets, i have it set so when all 6 targets are = true then the game time and score stops, then the new scene loads along with the game score for a final score results page.
This all works however now the main menu and quit button will not work, I loaded the actual scene up and when you press play it comes up with the error: ''Object reference not set to an instance of an object'' in reference to this script:
function OnGUI() { GUI.Label(Rect (10,30,200,20), "Score = " +"" +ScoreScriptFinish.finalScore); }
if you take the script off the buttons work and scene is okay, if you play from main menu and get to this scene it all works, the final score shows but then it freezes with that error.
Post your whole script and use the code button when posting code. I assume it's the finalScore variable you are trying to access and if you are trying to use Application.Quit() it doesn't do anything in the editor, but works after you build it.
don't have the code to hand as of yet, will try to post tomorrow.
none of the buttons work once its loaded that scene, if you try to play the scene directly it comes with the error straight away... the score codes are all static and I have dontdestroyonload etc... but it's having none of it :/
Your answer
![](https://koobas.hobune.stream/wayback/20220613083112im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
DontDestroyOnLoad Game Score/Lives 1 Answer
access a gameobject from another scene at design-time 2 Answers
Shared canvas for some scenes 1 Answer
Keeping score problems dontdestroyonload 2 Answers