NullReferenceExeption Error

So I keep getting this error saying "Object Reference not set to an instance of an object"
TextController.State_ruins () (at Assets/TextController.cs:51)
TextController.Update () (at Assets/TextController.cs:24)

Here are my lines: (51)
and (24)

Any ideas on what i need to do?

Hi Christopher,

Can you paste your full script into a reply here please. Line numbers don’t correspond if you take snippets like this, it is therefore a little tricky to determine which line was 51.

If I had to guess at the moment I would suggest that perhaps you haven’t dragged your Text UI object from the Hierarchy to the exposed Text variable in your script component. This would generate this error as you are then trying to set the text property of the Text UI object which it doesn’t have a reference to.

See also;

Thanks Rob! That fixed it!

1 Like

Great to hear :slight_smile:

Privacy & Terms