DontDestroyOnLoad Duplicates My Object

I have a script on an empty game object which contains my global variables.
I want this script to stay intact through all scenes so I write…

function Start()
{

	globalVars = GetComponent(GlobalFunctionsScript);
	DontDestroyOnLoad (globalVars);
	
}

The problem is that when I returen to the scne where the empty game object originally exists I notice in the inspector there are now 2. If I continue to leave and re-enter the scene the game object containing my global variables is duplicated…again and again…

Should I care? Is this just an ‘editor’ thing? AFter all, the game is always using the first one that I ‘didnt destroy’.

Is there a better way to store my global vars or is this the generally used method?

Cheers

If that gameobject is in each scene to start with, you’re basically keeping the old one intact as well as the new one. And then when you load a third scene you’re keeping both of those intact as well as the newest one.

You should place the first one in a scene that the player won’t be able to return to, and then don’t put that object in any other scenes.

A lot of the time people will spawn such objects in the scene for their splash screen, as you’re never likely to load that twice.