Events
The signal type behind every event in the API, and the Connection object it returns.
part.Touched:Connect(function(player)
print(player.Name .. " touched " .. part.Name)
end)Each handler call runs in its own task, so handlers can yield with task.wait without blocking other handlers. An error ends that call only, and the connection stays active. Each script is limited to 2048 connections.
Methods
Connect
event:Connect(fn: function): ConnectionRegisters fn to be called each time the event fires. Returns a Connection.
Once
event:Once(fn: function): ConnectionRegisters fn for the next firing only, then disconnects it.
humanoid.Died:Once(function()
print("Gone")
end)Wait
event:Wait(): ...Yields the current task until the event fires, then returns the event's arguments.
local player = Players.PlayerAdded:Wait()Connection
Disconnect
connection:Disconnect()Disconnects the handler.
local connection
connection = part.Touched:Connect(function(player)
player:SendMessage("You found the secret!")
connection:Disconnect()
end)Connected
connection.Connected: booleantrue while the handler is connected.