- Home /
Duplicate Question
NullreferenceExeption on this script.
I've been working on a game. Now I finished up this script today, along with a few more. Not to brag or anything, lol. But that's not relevant. Now I have this battery life thing, so it shows how much you've got left before you have to find more, And when I assign all the things and such. I get a nullreference exeption on the GUIText that shows the value. Here is the code. It's JavaScript by the way.
public var script : flashlight;
public var gui : GUIText;
public var num;
function Start() {
script = GameObject.Find("flashlight").gameObject.GetComponentInChildren(flashlight);
num = script.currentbatteryLife();
}
function Update(){
gui.guiText = num.toString();
}
function OnGUI() {
}
You do know that the tag page for nullreferenceexception has over 45 pages of questions and answers?
Follow this Question
Related Questions
Why this Error when trying to add a score using the new GUI ? 0 Answers
GuiText not Displaying Asian Characters unless a latin character is present also 0 Answers
Trying to convert AutoType GUI Text script to Text mesh (3D text) 1 Answer
Score going up every second 1 Answer
GUIText problem 0 Answers