getconnections
Gets all connections to a signal.
Syntax
getconnections(signal: RBXScriptSignal) -> {Connection}Aliases
get_signal_cons
Parameters
| Parameter | Type | Description |
|---|---|---|
signal | RBXScriptSignal | The signal |
Returns
| Type | Description |
|---|---|
{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/Method | Type | Description |
|---|---|---|
Enabled | boolean | Whether the connection is active |
ForeignState | boolean | Whether it's from a different Luau state |
LuaConnection | boolean | Whether it's a Luau connection |
LuaWaitConnection | boolean | Whether the connection represents a waiting thread |
Function | function? | The connected function, or nil for a foreign/C connection |
Thread | thread? | The connection's thread, or nil for a foreign/C connection |
Fire(...) | method | Fire this connection only |
Defer(...) | method | Deferred fire |
Disconnect() | method | Disconnect this connection |
Disable() | method | Temporarily disable |
Enable() | method | Re-enable after disable |
Related Functions
firesignal- Fire all connections