getconnections

Gets all connections to a signal.

Syntax

getconnections(signal: RBXScriptSignal) -> {Connection}

Aliases

  • get_signal_cons

Parameters

ParameterTypeDescription
signalRBXScriptSignalThe signal

Returns

TypeDescription
{Connection}Array of Connection objects

Description

getconnections returns all current connections to a signal, allowing you to inspect, fire, disable, or disconnect them individually.

Example

local event = Instance.new("BindableEvent")
event.Event:Connect(function(message)
    print(message)
end)

local connections = getconnections(event.Event)

print("Total connections:", #connections)

for i, conn in ipairs(connections) do
    print(i, "Enabled:", conn.Enabled)
end

event:Destroy()

Disconnecting All

local function disconnectAll(signal)
    for _, conn in ipairs(getconnections(signal)) do
        conn:Disconnect()
    end
end

local event = Instance.new("BindableEvent")
event.Event:Connect(function() end)

disconnectAll(event.Event)
print(#getconnections(event.Event)) -- 0
event:Destroy()

Disabling Specific Connections

local event = Instance.new("BindableEvent")
event.Event:Connect(function() end)

local connections = getconnections(event.Event)

for _, conn in ipairs(connections) do
    if conn.Function then
        -- Check if it's the function we want to disable
        conn:Disable()
    end
end

event:Destroy()

Inspecting Connection Functions

local event = Instance.new("BindableEvent")
event.Event:Connect(function()
    print("inspect me")
end)

local connections = getconnections(event.Event)

for _, conn in ipairs(connections) do
    if conn.LuaConnection and conn.Function then
        print("Found Luau connection")
        for index, constant in ipairs(debug.getconstants(conn.Function)) do
            print(index, constant)
        end
    end
end

event:Destroy()

The Connection Object

Each connection returned has the following properties and methods:

Property/MethodTypeDescription
EnabledbooleanWhether the connection is active
ForeignStatebooleanWhether it's from a different Luau state
LuaConnectionbooleanWhether it's a Luau connection
LuaWaitConnectionbooleanWhether the connection represents a waiting thread
Functionfunction?The connected function, or nil for a foreign/C connection
Threadthread?The connection's thread, or nil for a foreign/C connection
Fire(...)methodFire this connection only
Defer(...)methodDeferred fire
Disconnect()methodDisconnect this connection
Disable()methodTemporarily disable
Enable()methodRe-enable after disable