NullReferenceException: Object reference not set to an instance of an object.

Is your particle system assigned to the field in the Inspector on your script?

A Null Reference Exception (NRE) is caused when you’re trying to access a method or property on a null object – in other words, trying to get something from nothing.

Pretend I give you a set of instructions:

  • I will hand you a package of Oreos.
  • Open the package
  • Take out a cookie.
  • Eat the cookie.
  • Close the package.

I hand you the package, you open it, and the container is empty. Your “code” would fail at line 4, because you’d be trying to eat a cookie that doesn’t exist. That’s an NRE.

@Kurt-Dekker gave you some great tips on how to find that problem. @MartinMa just straight up gave you the answer. What part are you having difficulty understanding?

2 Likes
System.NullReferenceException: Object reference not set to an instance of an objec
I am getting an error called: nullreReferenceException and i have the same code as on the tutorial
NullReferenceException: Object reference not set to an instance of an object
Object reference not ser to an instance of an object
Null pointer dereference error
How to add rotation to a movement script
Script problem out of nowhere.
Why is this code not effectively referencing the object's script?
Missing Reference Exception
Error with Event Trigger
Camera Movent with Character
Can you retrieve values from a public Scriptable Object script?
'GameObject[]' does not contain a definition
error while trying to set avatar for rig
How to fix null reference exception problem
Strange NullReference Error
Null reference, activating function from another script, as it is not shown on the button onclick
Issue to add a non-mono instance of a class to a list
NullReferenceException but don't know why?
Null Reference Exception even though I assigned it in the editor
Why am I getting Null Reference Exception inspite of checking if the Object is not null to execute s
Null Reference Error For No Reason
Object reference not set to an instance of an object
After I updated from 2019 to 2020.3 I started getting a strange error on Slider objects
Trying to add structured, but unknown content/number, data and methods to a pre-existing object
NullReferenceException: Object reference not set to an instance of an object
for some reason unity is giving me this error
NullReferenceException
NullReferenceException Console Error
ArgumentOutOfRangeException ERROR! Help to fix then;
Keep getting error messages with bullet script
Help wanted--Lesson 5.2 - Keeping Score--5.Add score when targets are destroyed
Help needed accessing a variable from another script
Referencing object script on collision works, but Unity throws object reference error.
Random null reference exception (only happens sometimes)
NullReferenceException: Object reference not set to an instance of an object.
This object outline script works but I'm getting "Object instance not set to reference" error
Lists returning null
I have some problems with my Script about fps D:
Object reference not set to instance of an object
Script Order
error message shows even though the code runs...what the heck
Another day, another compile error
Why does line7 give null reference exception and not lets me make a set acessor for playerName field
How can ı solve null reference exception error
scene pausing because of nullref error
Need Help
Creating render textures and materials at runtime
My healthbar code keeps getting null reference exception errors
Guys I'm getting a NullReferenceException pls help me
how to assign the player as a prefab (C#)
Loading screen issue in script or loadingbar any help me how can solve
Shmup Drone Error
2D Raycast.transform.gameobject Returns a Null Reference When Adding a Distance Variable
How can ı solve null reference exception problem
NullReferenceException with new input system
Unity as a Library cause crashes a live application
I cannot pass an UI object via the inspector
NullReferenceException: Object reference not set to an instance of an object
Object reference not set to an instance of an object - Trying to set IK target to a GameObject but g
MissingReferenceException: The object of type '' has been destroyed but you are still trying to acce
Jump to start of IF-Statement
Can you explain null reference to me and how to avoid it?
object reference not set to an instance of an object
VR Oculus Quest Crash
MissingReferenceException
How do I make my code work?
Our mobile game crashes on android devices
Object reference not set to an instance of an object issues
There are some Errors and I am not very sure where is the problem coming from
NullNullReferenceException: Object reference not
Doing animations for third person controller
Referencing other script causes error, causes "void start" to become unused
NullReferenceException
I get the error "object reference not set to an instance of an object" in line 17 of my code