Binder
Bind a class to instances by tag, class name, ancestor or predicate, and clean up when they leave.
Binder watches the game for instances that match a filter and constructs your class for each one, handing it a Trove that is cleaned when the instance no longer matches. Filters combine CollectionService tags, class whitelists, ancestor whitelists and custom predicates, and a priority lets several binders construct in a defined order on the same frame. It is the successor to Mechanic.
Use it when
- You build gameplay as components attached to tagged parts or models (doors, buttons, pickups, NPCs).
- You want deterministic setup order between systems and guaranteed cleanup with no leaked connections.
Install
Studio Wally
Using the Studio Wally plugin:
- Open the widget.
- Search
kashtheking/binder. - 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:
Binder = "kashtheking/binder@0.6.3"
local Binder = require(ReplicatedStorage.Packages.Binder)
Dependencies
Wally installs these automatically:
Credits
Trove and Signal are by sleitnick (RbxUtil). Predicates is my own package.
API
Every constructor, method, property and type is documented on the Binder 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.