hooksignal
Routes a signal's executor-owned connections through a callback.
Every Lua connection this VM owns on the signal is replaced with a wrapper. Engine connections, connections belonging to another VM and Wait slots are left alone, so a signal with no connection of ours is a no-op rather than an error.
The hook is called as hook(info, ...) with the fired arguments after info. Returning true lets the original callback run with those same arguments; any other return blocks it. An error raised inside the hook propagates to the firing code.
hooksignal(signal: RBXScriptSignal, hook: (info: table, ...any) -> boolean?): ()Parameters
| Parameter | Type | Description |
|---|---|---|
signal | RBXScriptSignal | Signal whose connections are wrapped. |
hook | function | Callback receiving the info table and the fired arguments. |
Info fields
| Field | Type | Description |
|---|---|---|
Function | function | The original connected callback. |
Connection | table? | The matching row from getconnections, when one was found. |
Index | number | One-based position of that row, or 0 when no row matched. |
Example
local bindable = Instance.new("BindableEvent")
bindable.Event:Connect(function(value) print("original", value) end)
hooksignal(bindable.Event, function(info, value)
print("hook", value)
return true
end)
bindable:Fire("example")Example output
hook example
original exampleSee issignalhooked and restoresignal.
