Want a special badge and 30 bux? Make some PolyWorld! Content and post it in the Creations forum!
Dark mode is incomplete! Please report any issues to the Discord.

Event

LocalScripts Scripts Not creatable

Events are signals you can listen to with Connect.
Most class Events pages list an Event for each signal, such as Part.Touched or Players.PlayerAdded.


Overview

Methods


API

Methods

Connect

Connect(listener: function) : Connection
Starts listening to the Event.
Each time the Event fires, listener is called with the Event's arguments.
Returns a Connection you can Disconnect later.

local connection = part.Touched:Connect(function(player)
    player.Character:Kill()
end)

Once

Once(listener: function) : Connection
Same as Connect, but the listener runs at most once.
After the Event fires, the Connection disconnects on its own.

Wait

Wait() : ...
Yields the current script until the Event fires.
Returns the same arguments the listener would receive.

local player = Players.PlayerAdded:Wait()
player:Notify("Welcome!")

DisconnectAll

DisconnectAll() : void
Disconnects every Connection currently listening to this Event.


Older handlers

Defining a global function such as function Touched(player) in a Script body is still supported for compatibility.
Prefer Connect on the Event instead.
No longer recommended for use.