Quick answer: Reference rooms by asset name, use room_next/room_exists for sequential flow, and validate data-driven room names via asset lookup before navigating.

Room IDs are assets, and navigation by arithmetic or stale data crashes with this. Sequential-level games hit it on the last level. Here is the safe pattern.

How to fix it

1. Guard sequential progression

Replace room_goto(room + 1) with if (room_next(room) != -1) room_goto(room_next(room)); else show_credits(); — the end of the room order must be a designed case.

2. Fix stale references

Deleted or renamed rooms leave dead identifiers in code and level-select menus — project-search the old names after any room reorganization.

3. Validate data-driven navigation

Level data naming rooms as strings should resolve via asset_get_index(name) with a check for -1 — a typo in a config file must not crash the shipped game.

4. Centralize level flow

One level-manager script owning all room transitions gives you a single place for validation, transitions, and analytics — scattered room_goto calls are where illegal indices hide.

Catching the ones you can't reproduce

The hardest version of this to fix is the one you can't reproduce — it only happens on a player's hardware, OS, driver, or save state, under conditions that simply aren't present on your machine. A report that says “it crashed” or “it froze” gives you nothing to act on, so the bug survives release after release while quietly costing you players.

Automatic error capture closes that gap. Each failure arrives with its full stack trace, the device and OS, the build number, and a breadcrumb trail of what the player did right before it broke, so even a failure you have never seen becomes a specific, reproducible issue. Fold identical failures into one signature ranked by how many players each hits, and your worklist sorts itself worst-first instead of arriving as a stream of vague complaints.

This is where a tool like Bugnet earns its place. Its SDK captures every GameMaker error automatically with the full stack trace plus device, OS, memory, build, and game-state context, folds duplicates into one grouped issue with an occurrence count, and ties each to the build it first appeared on — so you fix the problem that hurts the most players first and confirm it is gone when its signature disappears from the next release.

Most of the time the fix is small. Seeing the failure clearly is the part that actually costs you.