Once
Subscribe for a single emission, then disconnect. ~>Once is janitor-managed.
Syntax
Section titled “Syntax”name::Once(fn);name~>Once(fn);Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
fn | func | Listener. |
Return value
Section titled “Return value”A connection.
Luau emit
Section titled “Luau emit”name:Once(fn)
Description
Section titled “Description”Use for “first player only”, one-shot setup, or handshake events.
Example
Section titled “Example”players.PlayerAdded~>Once(func (Player player) { post("First player only");});Emits:
janitor:Add(players.PlayerAdded:Once(function(player: Player) print("First player only")end), "Disconnect")