Skip to main content
Opens a new communication channel, then hands back its id and event.
Scripts running on different actor threads (e.g. through run_on_actor) don’t share _G or shared. Open a channel to bridge that gap: call create_comm_channel() on one side, send the returned id to the other side, and both sides talk over the same event. The second return value is a Roblox BindableEvent. Use :Fire(...) to send a message. Use .Event:Connect(...) to receive one, or .Event:Wait() to yield until the next message arrives.

Returns

A tuple: Both values are nil if the channel could not be opened.

Example

The main thread opens a channel, connects a handler, and starts a worker thread with the id. The worker resolves the same channel with get_comm_channel, fires two messages back, and the main thread catches them on .Event:Connect.
The id is just a number, so the other thread learns it by being handed it. The simplest way is to pass it as one of the ... arguments of run_on_actor(actor, script, ...) when you start the worker thread. On that side, use get_comm_channel(id) to turn the id back into the shared event.