Using Singleton but getting a null reference

I have tried looking at other similar questions but nothing seems to get rid of the error i get.
NullReferenceException: Object reference not set to an instance of an object
I dont know if i have missed something obvious this is my first time using singletons thanks for any help.

The singleton Script

 public class ManagerScript : MonoBehaviour {
    public static ManagerScript Instance { get; private set; }

    public int cameraOverview = 0;

    private void Awake() {
    if (Instance == null) {
        Instance = this;
        DontDestroyOnLoad(gameObject);
    }
    else {
        Destroy(gameObject);
    }
}

}

Using the singleton

void OnMouseDown()  {
    if (ManagerScript.Instance.cameraOverview == 1) {
        Debug.Log("clicked");
    }
}

Hello there,

I use Singletons quite a bit, and this is usually the structure I use:

    #region Singleton
    public static ManagerScript Instance
    {
        get
        {
            if (instance == null)
                instance = FindObjectOfType(typeof(ManagerScript)) as ManagerScript;

            return instance;
        }
        set
        {
            instance = value;
        }
    }
    private static ManagerScript instance;
    #endregion

Otherwise, your “using the singleton” code looks good to me.

Note: You have to make sure your Singleton is placed on an object in the scene.

Hope that helps!

Cheers,

~LegendBacon

I use the same code the OP is using, only I place all my Singleton classes on their own root objects, which I believe DontDestroyOnLoad() requires.