get_comm_channel
Retrieves an existing communication channel by its identifier.
Syntax
get_comm_channel(id: number) -> BindableEventParameters
| Parameter | Type | Description |
|---|---|---|
id | number | The one-based channel identifier |
Returns
| Type | Description |
|---|---|
BindableEvent | The 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
Related Functions
create_comm_channel- Create a channelrun_on_actor- Run code on an actor