Skip to content

Search documentation

Enter at least two characters.

    Connection

    SDK 0.1.0-preview.1 · ExperimentalDownload & release notes ↗

    The connection returned by Signal:Connect. Disconnect it when you no longer need the callback.

    Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.

    local Window = Instance.new("Window", {
    Title = "LUI example", Size = UDim2.fromOffset(560, 280),
    })
    local Status = Instance.new("TextLabel", {
    Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170),
    Size = UDim2.new(1, -32, 0, 72),
    })
    local Button = Instance.new("TextButton", {
    Parent = Window, Text = "Try it", Size = UDim2.fromOffset(220, 44),
    Position = UDim2.fromOffset(16, 16),
    })
    local Connection = Button.Activated:Connect(function() Status.Text = "Activated" end)
    task.delay(5, function()
    Connection:Disconnect()
    Status.Text = "Callback disconnected"
    end)
    Window.Visible = true

    Expected result: The button works for five seconds, then its explicit connection is disconnected. Destroying the button would also disconnect its own signals.

    Full type declaration — for type checking and deeper reference

    The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.

    export type Connection = { read Disconnect: (Self: Connection) -> () }

    SDK declaration source. This page explains a public type, not a separate feature you must initialize.