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.
Luau
CommChannel:Connect(callback: Function) -> RBXScriptConnectionParameters
Call this method with a CommChannel receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
| Parameter | Type | Description |
|---|---|---|
callback | Function | Function called with the values passed to Fire. |
Returns
RBXScriptConnectionAn RBXScriptConnection that can be disconnected.
Example
Luau
local _, channel = create_comm_channel()
local connection = channel:Connect(function(message)
print(message)
end)
channel:Fire("connected")
connection:Disconnect()