Threads
The threads module allows you to run scripts that are not attached to any Scene, Actor, or Trigger. Threads are useful for background processes, global game logic, or situations where no specific actor or trigger is appropriate.
How Threads Work
A thread is a standalone script that runs alongside the rest of your game. Unlike actor or scene scripts, threads are not tied to any entity — they exist independently and continue running regardless of what happens in the scene.
When a thread's script finishes executing, the thread stops. If you want a thread that runs continuously, place its logic inside a Loop event.
Thread Slots
By default, you can create up to 5 threads. This can be increased in the Maximum Elements settings.
Each thread slot is independent — you can have multiple threads running simultaneously, each with its own script.
When to Use Threads
Threads are best suited for:
- Background music control — Changing music based on game state without tying the logic to a specific actor.
- Global counters or timers — Tracking time or score that persists across actor interactions.
- Monitoring conditions — Continuously checking if a condition is met (e.g., "if all enemies defeated, open the door").
- Cutscene orchestration — Coordinating multiple actors from a single script that doesn't belong to any one of them.
Threads vs Timers
Both threads and timers run scripts independently, but they serve different purposes:
- Threads run a script once (or continuously with a loop) and are good for ongoing background logic.
- Timers fire a script at regular intervals and are good for periodic actions on a fixed schedule.
Tips
- Always include an Idle or Wait in looping threads to avoid freezing the game.
- Threads are a good way to handle global game state that doesn't belong to any particular actor.
- Remember that threads persist until their script finishes. If you change scenes, any running threads will continue unless you explicitly stop them.

