DontDestroyOnLoad duplication despite having code that should stop it

I have an object with DoNotDestroyOnLoad and I have code in place that should stop it from duplicating each time I enter the scene where it was instantiated. The weird thing is that only one other duplicate will show up in the editor, but the effects of having more than that will occur.

Here is the code I’m using that pertains to this issue:

public class gameManagerScript : MonoBehaviour {

public static gameManagerScript Instance;

// Use this for initialization
	void Start () {

if (Instance) {
			DestroyImmediate (gameObject);
		} else {
			DontDestroyOnLoad (gameObject);
			Instance = this;



I’ve also tried using FindGameObjectsWithTag and checking to see if the length is more than one, but nothing I try is working.

Try something like this instead:

    if(Instance == null)
        Instance = this;
    else if(this != Instance) {

Try this:

I fixed it. The problem wasn’t related to how I was doing it. It was because I left the stuff I wanted the script to do on the outside of the if statement.