When loading the scene, I get missing references

I have bunch of managers, like GameManager, LevelManager, UIManager, etc.
All of them declare a public static variable of their class type and call it “instance”. Then all of them have this code in their Awake

void Awake
{
	if (instance != null)
	Destroy(gameObject);
	
	instance = this;
	DontDestroyOnLoad (gameObject);
}

Basically they’re singletons so that I can reference them easier.
When I’m trying to load or reload the level, I get this error: “The object of type ‘GameObject’ has been destroyed but you are still trying to access it.”

All my managers are in DontDestroyOnLoad section of the scene, i.e. the gameobject and the scripts on them are preserved. I don’t understand why the hell am I getting this error when I reload the scene and try to access these statics.

Can someone make sense of this?

EDIT:
@hexagonius @jackishere @RobAnthem @ExtinctSpecie
I think the problem here may be deeper since out of all those managers, only a specific one is throwing that error and i have problem debugging it. here’s what’s happening:

The loader is instantiating all the managers like so

void Awake ()
{
	if (LvlGenerator.instance == null)
		Instantiate(lvlGenerator);

	if (GameManager.instance == null)
		Instantiate(gameManager);

    //etc.
}

then GameManager is calling this method upon being instantiated

void SetUpNewScene()
	{
		SceneManager.LoadScene("Scene1");
        LvlGenerator.instance.GenerateLevel();
		UIManager.instance.SetUpDeathScreen();
	}

*here if I omit "SceneManager.LoadScene(“Scene1”) then the entire thing works fine. It’s the loading that screws it. *

UIManager for example works fine, and LvlGenerator isn’t null either. It goes through and calls GenerateLevel() method. Which looks like this

public void GenerateLevel()
{
	transform.position = Vector3.zero; //moves LvlGenerator to 0,0,0 so that we start building from those coordinates
	StartCoroutine(GenerateLevelCoroutine());
}

then it starts the coroutine which is quite some code, I’ll cut out most part and leave the one that throws the error (which I don’t understand).

IEnumerator GenerateLevelCoroutine()
	{
		int floorTilesRemaining = levelSize;
		SpawnFloorTile ();
		floorTilesRemaining--;
	while(floorTilesRemaining > 0)
	{
		if (floorTilesList.Count > 0) 
		{
			for (int i = 0; i < floorTilesList.Count; i++) 
			{
				if (transform.position == floorTilesList *.transform.position)*
  •   			{*
    

// some code

  •   			}*
    
  •   		}*
    
  •   		SpawnFloorTile ();*
    
  •   		floorTilesRemaining--;*
    
  •   	}*
    

yield return null;
}
}
THIS line “if (transform.position == floorTilesList _.transform.position)” is throwing an error mentioned above (The object of type ‘GameObject’ has been destroyed but you are still trying to access it.)._
When I try to debug it, none of the variables there are null or anything.
floorTilesList is declared in the same script as the error
public List floorTilesList = new List();
I still don’t understand why this is happening : (

I looked into this a bit more and there doesn’t seem to be an easy explanation of why this is happening. I figure it’s something in the coroutine that goes off while the scene is loading, or maybe something doesn’t get preserved in the DontDestroyOnLoad.
In any case, it doesn’t make sense for me to get stuck on this any longer so I just removed all these singletons from DontDestroyOnLoad and when I load/reload a scene, everything gets wiped and it’s working.

For educational purposes I’d still be curious to know why this was bugging out, so if anyone will figure it out, please do post here.

it’s because you are destroying the gameobject then assigned the null to the instance

if (instance != null)
{
Destroy(gameObject);
}
else
{
instance = this;
DontDestroyOnLoad (gameObject);
}

because the second time you destroy your reference from the first time but don’t return. the next call is the try of assigning the destroyed reference to the variable, which fails. destruction does not stop code execution.

even if the variables are static when you destroy that script the variables get destroyed as well
try creating a new script that saves the things you want to save

for example

public class SaveVolume
{
    public static int volume { get;set;}
}

I’ve been stuck for two days on a similar issue. Singletons for data persistance seems not to work in some cases. I used the tutorial at Implement data persistence between scenes - Unity Learn and built on it for my application, but eventually i got “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.”