How would I fix multiple gameobject loads from this script?

Between loading scenes, I want to not destroy my gameobject, so I’m using this script…

public class DontDestroy : MonoBehaviour {

void Awake()
{
    DontDestroyOnLoad(transform.gameObject);
}

This script works when I enter level 2, but my problem is that I want to be able to toggle between level1 and level2, and when I go back into level1, it loads to orignal scene with the orignal object and also it brings in the object with this script attached to it like it should, but now I have 2 of the same objects in my scene…My question is, How would I delete the Orignal object when loading into a previous scene? or, is there a better way to go about this, because I’m a bit new to this and any feedback would be great. Thank you :slight_smile:

What you’re looking for is called a Singleton system, which makes sure you only have one of a certain object in your scene. Unity has a Live Training session where they cover that along with other persistence topics here:
PERSISTENCE - SAVING AND LOADING DATA