Signal:Connect Synchronous

  • KawaiiSignal:Connect
  • PsmSignal:Connect
  • VoltSignal:Connect

Subscribe a callback to a custom Signal. Each Fire call sends its arguments to the callback until the returned connection is disconnected.

Syntax
Luau
Signal:Connect(callback: Function) -> SignalConnection

Parameters

Call this method with a Signal receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.

Function parameters
ParameterTypeDescription
callbackFunctionFunction that receives the arguments passed to Fire.

Returns

SignalConnection

A SignalConnection with Connected and Disconnect.

SignalConnection fields
Luau
SignalConnection = {Connected: boolean, Disconnect: Function}

Usage notes

Keep the returned connection when you need to stop listening independently of other subscribers. Callbacks run synchronously during Fire.

Example

Example
Luau
local updates = Signal.new()
local subscription = updates:Connect(function(count)
    print("Count:", count)
end)
updates:Fire(1)
subscription:Disconnect()
updates:Destroy()
Kawaii documentation