I have a GameObject that has a script that uses another GameObject (GameObject2)for values. However, when the game ends and I switch scenes to the title scene, it deletes all GameObjects. When you click start to go back to the main scene, the GameObject can’t find GameObject2, so I get errors in the console and the whole game breaks. Can anyone help with this?
Use DontDestroyOnLoad:
I forgot to mention this is the main post, but I can’t use Don’t Destroy On Load because it would make copies of the objects I wanted to keep, which would also break the game.
DontDestroyOnLoad shouldn’t be causing this, at least not on its own.
If you have a script that’s spawning the GameObjects when the scene loads, have it check if the objects already exist & prevent spawning them again if so.