Skip to content
Untitled Sandbox - Developer Documentation
docs/types/Event

Event<T...>

Something that happens in the game, such as a player joining, which your scripts listen to with connect or wait.

Event:connect

method

Runs your function every time the event fires, each time in a new thread.

Event:connect(callback: (T...) -> (), options: ConnectOptions?) -> Connection
example
door.touched:connect(function(part, player) print("touched") end, { debounce = 1 })

Use it forreacting to a player touching a token, joining, or any other event.

callbackRuns at each firing, with the event's values.
optionsoptionalDebounce, per player, once and a filter.
Build a connect calldebounce · per_player · once · filter
  • debounce

    How many seconds after each run that new firings are skipped, which can be 0 or more.

  • per_player

    Whether each player gets their own debounce, while a firing without a Player uses the shared one.

  • once

    Set it to true to disconnect after the first run, so the function only runs once.

  • filter

    A function that gets the event's values and returns whether this firing counts, and a firing that doesn't count, or whose filter errors, never uses up once or debounce.

Event:wait

method

Pauses the script until the event fires next, then gives you its values.

Event:wait() -> T...
example
local newcomer = players.joined:wait()

Use it forwaiting for the first player to join before the game starts its first round.

↑ ↓ moveEnter openEsc close