---
title: "Signals & Connect()"
description: "Subscribe a Luau function to a Glorpia event and disconnect the connection when needed."
canonical: "https://docs.glorpia.com/scripting/functions/signals"
markdown: "https://docs.glorpia.com/scripting/functions/signals.md"
---
# Signals & Connect()

Subscribe a Luau function to a Glorpia event and disconnect the connection when needed.

**Category:** Scripting / Events

## Connect

```luau
signal:Connect(callback)
```

| Name | Type | Description |
| --- | --- | --- |
| `callback` | function | Function called whenever the signal fires. |
| `return` | connection | Connection object for checking or disconnecting the subscription. |

## Studio autocomplete

When Studio knows that a member is a signal, autocomplete inserts the signal name together with `:Connect()` and places the caret inside the parentheses. This includes `Touched` and the TextButton signals `Activated`, `MouseButton1Click`, `MouseButton1Down` and `MouseButton1Up`.

## Connection

| Name | Type | Description |
| --- | --- | --- |
| `Connected` | boolean | True while the callback is still registered. |
| `Disconnect()` | method | Removes the callback from the signal. |

## Example: Connect And Disconnect

```luau
local RunService = game:GetService("RunService")
local elapsed = 0

local connection
connection = RunService.Heartbeat:Connect(function(deltaTime)
    elapsed = elapsed + deltaTime

    if elapsed >= 5 then
        connection:Disconnect()
    end
end)
```

> **Note:** A callback is allowed to disconnect itself while the signal is firing.

## Documented signals

- [BasePart.Touched](https://docs.glorpia.com/scripting/events/touched.md) — Server-authoritative or client-local physical contact events for BaseParts in Workspace.
- [TextButton](https://docs.glorpia.com/instances/textbutton.md) — Activated and primary mouse-button client signals.
- [Humanoid.Died](https://docs.glorpia.com/scripting/events/humanoid-died.md) — Fires when a Humanoid transitions from alive to dead.
- [RunService](https://docs.glorpia.com/services/runservice.md) — PreSimulation, Stepped, Heartbeat and CoreScript RenderStepped.
- [Players](https://docs.glorpia.com/services/players.md) — PlayerAdded and PlayerRemoving.
- [UserInputService](https://docs.glorpia.com/services/userinputservice.md) — CoreScript InputBegan, InputChanged and InputEnded.
