ArgumentException: The Object you want to instantiate is null.

Hey! I’m a beginner and I started creating a 2D game in unity based on tutorials. After trying to pass variables, obstacle spawning stopped working. And it’s not working, even after deleting code that I tried to use. It throws this error:

ArgumentException: The Object you want to instantiate is null.
UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at C:/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:374)
UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:197)
UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:276)
Spawner.Update () (at Assets/Spawner.cs:17)

Here’s a link to GitHub repository of this project:
https://github.com/ZuriPL/GameTroubleshooting

Please help me.

The error tells you what is wrong. You are trying to instantiate something, but that something is null. Which means it has no value, nothing is assigned to it. If it’s a public variable, make sure you assign something to it. In this case, it’s an error on line 17 of your spawner script within the Update method.

I know, the problem is that it’s assigned, but its unassigning variable after the scene restarts and i dont know why