What this script does
Expose events without handing every consumer the internal BindableEvent Instance.
- Best for
- Module state changes, UI updates, timer completion, inventory changes, and prototype architecture.
- Language
- Luau
- Version
- 1.0.0
- Validation
- Luau checked · Studio integration required
Official Luau 0.735 parsing and static analysis pass with Roblox host types stubbed. Test the actual Instance, service, or event integration in a separate Studio place before production use.
Included behavior
- Connect and once subscriptions
- Variadic event values
- Explicit destruction
Install in the stated runtime
- 1Create a ModuleScript named Signal.
- 2Paste the complete source and require it from a server or test Script in your own experience.
- 3Create one Signal per event, store returned connections, and destroy both the signal and connections with their owner.
Minimal usage example
local Signal = require(script.Parent.Signal)
local changed = Signal.new()
changed:connect(function(value) print("Changed", value) end)
changed:fire(42)
changed:destroy()Example inputs and result
- Supply
- A listener callback and values passed through fire.
- Expect
- Connected listeners receive the values until disconnected or destroyed.
These notes explain the example above. Read the complete source for every exported function and edge case before integrating it.
Complete source
No hidden import, minified block, or shortened loader.
--!strict
-- MIT License. Small BindableEvent-backed Signal for your own Studio modules.
local Signal = {}
Signal.__index = Signal
function Signal.new()
return setmetatable({ event = Instance.new("BindableEvent"), destroyed = false }, Signal)
end
function Signal:connect(callback: (...any) -> ()): RBXScriptConnection
assert(not self.destroyed, "Signal is destroyed")
return self.event.Event:Connect(callback)
end
function Signal:once(callback: (...any) -> ()): RBXScriptConnection
assert(not self.destroyed, "Signal is destroyed")
return self.event.Event:Once(callback)
end
function Signal:fire(...: any)
if not self.destroyed then self.event:Fire(...) end
end
function Signal:destroy()
if self.destroyed then return end
self.destroyed = true
self.event:Destroy()
end
return Signal
1309eaf8638f95b4f9e462a598c8c753c24de0a2de932ab39fb1be58d1d8e0f0Outside this script’s scope
- Replicate across client and server
- Replace RemoteEvents
Found a problem or a better approach?
Tell us what failed, what you expected, and whether the issue happened in the Luau CLI or Roblox Studio. Suggestions for clearer types, safer server checks, or a more useful API are welcome.