get_comm_channel

Retrieves an existing communication channel by its identifier.

Syntax

get_comm_channel(id: number) -> BindableEvent

Parameters

ParameterTypeDescription
idnumberThe one-based channel identifier

Returns

TypeDescription
BindableEventThe requested communication channel

Description

get_comm_channel retrieves the BindableEvent created by create_comm_channel. An invalid ID raises an error.

Example

-- On main thread
local id, channel = create_comm_channel()
channel.Event:Connect(print)

-- Inside actor (via run_on_actor)
local actor = assert(getactors()[1], "No active actor state")
run_on_actor(actor, [[
    local channelId = ...
    local channel = get_comm_channel(channelId)
    channel:Fire("Hello from actor!")
]], id)

Notes

  • The channel ID is passed from the main thread to the actor
  • Use this inside actors to communicate back to the main thread