Scripting / Events
Signals & Connect()
Subscribe a Luau function to a Glorpia event and disconnect the connection when needed.
Connect
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)A callback is allowed to disconnect itself while the signal is firing.
Documented signals
BasePart.TouchedServer-authoritative or client-local physical contact events for BaseParts in Workspace.TextButtonActivated and primary mouse-button client signals.Humanoid.DiedFires when a Humanoid transitions from alive to dead.RunServicePreSimulation, Stepped, Heartbeat and CoreScript RenderStepped.PlayersPlayerAdded and PlayerRemoving.UserInputServiceCoreScript InputBegan, InputChanged and InputEnded.