Quick answer: A persistent object placed in every room creates a new persistent copy each time you enter. Place it only in the first room, or guard its Create event with an instance_number check.
A persistent obj_game_controller is placed in every room for convenience. After moving between rooms a few times, there are five controllers all running.
Persistent + Placed Everywhere = Duplicates
Persistent means the instance survives room changes. But if the object is also placed in the next room, GameMaker creates that room’s copy too — on top of the persistent one that travelled with you.
Fix 1: Place It Once
Put the persistent controller in only the very first room (or a dedicated init room). It then travels with the player; no other room re-creates it.
Fix 2: Self-Destruct Duplicates
// Create event of obj_game_controller
if (instance_number(obj_game_controller) > 1) {
instance_destroy();
exit;
}
// ... real init below ...
The first one to exist wins; any later copy destroys itself immediately. Safe even if a designer leaves it placed in a room.
Singleton Helper
For multiple singletons, a shared helper makes intent clear: if (!ensure_singleton(object_index)) exit; — the same instance_number guard, named.
Verifying
Move between rooms repeatedly. instance_number(obj_game_controller) stays at 1. Game logic that lives on the controller runs exactly once per step.
“Persistent objects travel with you. Placing them in every room makes copies — place once, or guard with instance_number.”
The instance_number guard is the robust choice for team projects — it survives a designer dragging the controller into a room by habit.