CommChannel:Connect Synchronous

  • CommChannel:connect

Subscribe a function to a communication channel’s event. Use the returned connection to stop receiving messages when your task is finished.

Syntax
Luau
CommChannel:Connect(callback: Function) -> RBXScriptConnection

Parameters

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

Function parameters
ParameterTypeDescription
callbackFunctionFunction called with the values passed to Fire.

Returns

RBXScriptConnection

An RBXScriptConnection that can be disconnected.

Example

Example
Luau
local _, channel = create_comm_channel()
local connection = channel:Connect(function(message)
    print(message)
end)
channel:Fire("connected")
connection:Disconnect()
Kawaii documentation