Skip to main content

Connection

Type

Represents a connection object obtained from instances.getconnections.

This object provides detailed information about a single connection to an RBXScriptSignal and allows manipulating it.

Connection objects can be compared with each other using the equality operator (==). Internally, this checks if they represent the same underlying connection slot.

Properties

ForeignState

This item is read only and cannot be modified. Read Only
Connection.ForeignState: boolean

A boolean indicating if the connection belongs to a different Luau Virtual Machine (e.g., an Actor thread) or is a C function connection.

Function

This item is read only and cannot be modified. Read Only
Connection.Function: ((...any) → ...any)?

The Luau function associated with this connection. Returns nil if ForeignState is true.

Enabled

Connection.Enabled: boolean

A boolean indicating if the connection is currently enabled. Setting this to false is equivalent to calling Disable, setting it to true is equivalent to calling Enable.

LuaConnection

This item is read only and cannot be modified. Read Only
Connection.LuaConnection: boolean

A boolean indicating if this is a connection to a Luau function (as opposed to a C function).

Thread

This item is read only and cannot be modified. Read Only
Connection.Thread: thread?

The Luau thread (coroutine) this connection belongs to. Returns nil if ForeignState is true.

IsOnce

This item is read only and cannot be modified. Read Only
Connection.IsOnce: boolean

A boolean indicating if this connection was created using ConnectOnce. Such connections automatically disconnect after firing once.

Functions

Disconnect

Connection:Disconnect() → ()

Disconnects the signal connection. After calling this, the Connection object becomes unusable and attempting to access its properties or methods will error.

Enable

Connection:Enable() → ()

Enables the connection if it was previously disabled.

Disable

Connection:Disable() → ()

Disables the connection without disconnecting it. The connection can be re-enabled later using Enable or by setting the Enabled property to true.

Fire

Connection:Fire(
...any--

Arguments to pass to the connected function.

) → ()

Fires the connected function immediately with the provided arguments. Does nothing if ForeignState is true. If IsOnce is true, the connection will be disconnected after firing.

Defer

Connection:Defer(
...any--

Arguments to pass to the connected function when deferred.

) → ()

Schedules the connected function to be executed later (deferred) with the provided arguments via task.defer. Does nothing if ForeignState is true. If IsOnce is true, the connection will be disconnected after firing.

Show raw api
{
    "functions": [
        {
            "name": "Disconnect",
            "desc": "Disconnects the signal connection. After calling this, the `Connection` object becomes unusable and attempting to access its properties or methods will error.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 71,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "Enable",
            "desc": "Enables the connection if it was previously disabled.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 80,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "Disable",
            "desc": "Disables the connection without disconnecting it. The connection can be re-enabled later using `Enable` or by setting the `Enabled` property to true.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 89,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "Fire",
            "desc": "Fires the connected function immediately with the provided arguments. Does nothing if `ForeignState` is true. If `IsOnce` is true, the connection will be disconnected after firing.",
            "params": [
                {
                    "name": "...",
                    "desc": "Arguments to pass to the connected function.",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 99,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "Defer",
            "desc": "Schedules the connected function to be executed later (deferred) with the provided arguments via `task.defer`. Does nothing if `ForeignState` is true. If `IsOnce` is true, the connection will be disconnected after firing.",
            "params": [
                {
                    "name": "...",
                    "desc": "Arguments to pass to the connected function when deferred.",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 109,
                "path": "impl/Types/Connection.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "ForeignState",
            "desc": "A boolean indicating if the connection belongs to a different Luau Virtual Machine (e.g., an Actor thread) or is a C function connection.",
            "lua_type": "boolean",
            "readonly": true,
            "source": {
                "line": 20,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "Function",
            "desc": "The Luau function associated with this connection. Returns `nil` if `ForeignState` is true.",
            "lua_type": "((...any) -> ...any)?",
            "readonly": true,
            "source": {
                "line": 29,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "Enabled",
            "desc": "A boolean indicating if the connection is currently enabled. Setting this to `false` is equivalent to calling `Disable`, setting it to `true` is equivalent to calling `Enable`.",
            "lua_type": "boolean",
            "source": {
                "line": 37,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "LuaConnection",
            "desc": "A boolean indicating if this is a connection to a Luau function (as opposed to a C function).",
            "lua_type": "boolean",
            "readonly": true,
            "source": {
                "line": 46,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "Thread",
            "desc": "The Luau thread (coroutine) this connection belongs to. Returns `nil` if `ForeignState` is true.",
            "lua_type": "thread?",
            "readonly": true,
            "source": {
                "line": 55,
                "path": "impl/Types/Connection.luau"
            }
        },
        {
            "name": "IsOnce",
            "desc": "A boolean indicating if this connection was created using `ConnectOnce`. Such connections automatically disconnect after firing once.",
            "lua_type": "boolean",
            "readonly": true,
            "source": {
                "line": 64,
                "path": "impl/Types/Connection.luau"
            }
        }
    ],
    "types": [],
    "name": "Connection",
    "desc": "Represents a connection object obtained from `instances.getconnections`.\n\nThis object provides detailed information about a single connection to an `RBXScriptSignal` and allows manipulating it.\n\nConnection objects can be compared with each other using the equality operator (`==`). Internally, this checks if they represent the same underlying connection slot.",
    "tags": [
        "Type"
    ],
    "source": {
        "line": 11,
        "path": "impl/Types/Connection.luau"
    }
}