Reloading Scene Causing Null Refference

Hello guys, i m making a FPS game. but whenever i load the scene 2nd time, i get alot of Null References. I know it has something to do with static variables used in 1 or 2 script files or game objects that do not destroy. But, my project has alot of files and somehow i cannot seem to understand the reason behind this issue.

If you want to go to the problem state here are the steps.

  1. Start The Game
  2. Press Escape
  3. Press Yes
  4. Press Start
  5. Look into console Window (You Will See : MissingReferenceException: The object of type ‘GameObject’ has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.)

Here is the complete project in Zip Format : https://archive.org/download/abc_TestGameArchive/Test.zip

Kindly download the project and take a look. It will be much appreciated. I am a beginner and still learning things.

Good day.

If you are receiveng a NullReferenceException, is because some variable is not assigned when trying to access it.

You must track the issue by debuging the code while executing it, discover what variable is null when try to access it,m and then discover why is null.

If you are using DontDestroyOnLoad, make sure the objects are not duplicated, or you are not deleting the object that try to acess…

Bye!