getconnections
Gets all connections to a signal.
Syntax
getconnections(signal: RBXScriptSignal) -> {Connection}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 connections = getconnections(game.Players.PlayerAdded)
print("Total connections:", #connections)
for i, conn in ipairs(connections) do
print(i, "Enabled:", conn.Enabled)
endDisconnecting All
local function disconnectAll(signal)
for _, conn in ipairs(getconnections(signal)) do
conn:Disconnect()
end
end
-- Disconnect all PlayerAdded handlers
disconnectAll(game.Players.PlayerAdded)Disabling Specific Connections
local connections = getconnections(workspace.Part.Touched)
for _, conn in ipairs(connections) do
if conn.Function then
-- Check if it's the function we want to disable
conn:Disable()
end
endInspecting Connection Functions
local connections = getconnections(someEvent)
for _, conn in ipairs(connections) do
if conn.LuaConnection and conn.Function then
print("Found Lua connection")
local constants = debug.getconstants(conn.Function)
print("Constants:", table.concat(constants, ", "))
end
endThe 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 Lua connection |
Function | function | The connected function (if accessible) |
Thread | thread | The connection's thread |
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