Quick answer: GameMaker room_restart wiping instance state you expected to persist? room_restart re-creates instances — promote shared state to a global or persistent object.
Player score resets every time the player dies. The Player instance was destroyed and re-created by room_restart.
Persistent Objects
Object has a Persistent flag. A persistent object survives room transitions and room_restart. Use sparingly — persistent objects don’t reset when you want them to either.
Global Variables
global.score += 100;Globals live outside any instance and persist across the entire session. Best fit for shared score / save state.
Manager Object
Create a singleton GameManager (persistent), store all cross-room state on it. Room_restart leaves GameManager alone; only the room’s instances refresh.
Reset on Explicit Action
Resetting score on Game Over ≠ resetting on room_restart. Wire score reset to a specific event, not to room lifecycle.
Verifying
Player dies and respawns: score persists. Player chooses “new game”: score resets cleanly.
“room_restart kills instances. Persistent state goes in globals or a GameManager.”
Avoid making everything persistent — that’s how stale state bleeds across levels in surprising ways. Pick the smallest persistent surface.