StateManager
No longer maintained. New projects should model state with Binder-bound objects or their own state machine.
Versions before 2.1.1 are broken. Install 2.1.1 only.
A named-state machine with enter/exit callbacks and a Trove per state.
StateManager holds a set of named State objects and moves between them with ChangeState. Each state's OnEnter callback receives a Trove that is cleaned on exit, so connections made inside a state never outlive it. States can be loaded from a folder of ModuleScripts.
Use it when
- You maintain a project already built on StateManager.
Install
Studio Wally
Using the Studio Wally plugin:
- Open the widget.
- Search
kashtheking/state-manager. - Press download and choose Shared module (recommended for almost every package).
Wally
Add this to the [dependencies] section of your wally.toml, then run wally install:
StateManager = "kashtheking/state-manager@2.1.1"
local StateManager = require(ReplicatedStorage.Packages.StateManager)
Dependencies
Wally installs these automatically:
Credits
Trove and Signal are by sleitnick (RbxUtil).
API
Every constructor, method, property and type is documented on the StateManager API page, generated from the doc comments in init.luau. Each entry links to its line in the source.
Help
Questions and bug reports: the Discord or a GitHub issue. See Help & contact for everything else.