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

I get this error in unity: NullReferenceException: Object reference not set to an instance of an object
PlayerSetup.OnDisable () (at Assets/Scripts/PlayerSetup.cs:96)

here is a screenshot of my playersetup script where the error comes from Imgur: The magic of the Internet

I don’t know what’s wrong pls help me

It seems your singleton GameManager has no instance.

  1. Did you forget to attach your Component (GameManager) to any object in hierarchy?

  2. In you GameManager script, did you assign a value for instance in the Awake function (not in Start function)?

void Awake () { instance = this; }

  1. Is the object in hierarchy which holds the GameManager component active?

  2. Are there any other scripts in scene that before running require GameManager to be already set up? If yes, consider defining an “Execution Order” in Edit > Project Settings > Script Execution Order.

It seems like you are trying to reference a gameobject (or some other kind of object) that is empty. If you see something in your inspector panel that says something like “empty (gameobject)” then drag over the gameobject/script/sprite/whatever you are trying to reference into it and it should work perfectly.

==> Create GameObject attach GameManager Script
==> In Awake() Method

 private static GameManager instance;

public static GameManager Instance
{
    get
    {
        if (!instance)
        {
            instance = FindObjectOfType(typeof(GameManager )) as GameManager ;

            if (!instance)
            {
                Debug.LogError("There needs to be one active GameManager script on 
          a GameObject in your scene.");
            }
        }
        return instance;
    }
}
   Awake()
  {
      instance = this;
      DontDestroyOnLoad(this);
  }

==> Add GameManager in Script Execution Order.