Connect
Subscribe until Disconnect. Prefer ~>Connect so Janitor owns the connection.
Syntax
Section titled “Syntax”name::Connect(fn);name~>Connect(fn);Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
fn | func | Listener. Arguments match the signal payload. |
Return value
Section titled “Return value”A connection with :Disconnect().
Luau emit
Section titled “Luau emit”name:Connect(fn) — or janitor:Add(..., "Disconnect")
Description
Section titled “Description”Works on signal<T>, RBXScriptSignals (PlayerAdded), and anything with :Connect.
Example
Section titled “Example”players.PlayerAdded::Connect(func (Player player) { post(player.Name);});Emits:
players.PlayerAdded:Connect(function(player: Player) print(player.Name)end)See also
Section titled “See also”Once · operator-janitor · Fire · lambda