getconnections

Inspects a signal's connections.

Syntax

Signature
getconnections(SignalOrInstance: table, Event: string?) -> {Connection}

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
SignalOrInstancetableSupported signal, or instance containing the named event.
Eventstring?Event name when the first argument is an instance.

Returns

TypeDescription
{Connection}Snapshot of connected handler records. Unsupported signal layouts raise errors.

Notes

Accepts a signal directly or an instance followed by an event name. Returns records for currently connected handlers. Each record has Function, Connected, Fire(...), and Disconnect(). Thread is currently nil. Fire directly calls the stored callback, even if that connection is later disconnected.

Example

Luau
local Event = Instance.new("BindableEvent")
Event.Event:Connect(function(Message)
    print("Callback:", Message)
end)

for _, Connection in getconnections(Event.Event) do
    print(Connection.Connected, Connection.Function)
    Connection:Fire("Direct callback invocation")
    Connection:Disconnect()
end
Event:Destroy()