> ## Documentation Index
> Fetch the complete documentation index at: https://docsuncv2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# create_comm_channel

Opens a new communication channel, then hands back its id and event.

```luau theme={null}
create_comm_channel(): number?, BindableEvent?
```

Scripts running on different actor threads (e.g. through `run_on_actor`) don't share `_G` or `shared`, so they . Used to open the bridge for that case: call `create_comm_channel()` on one side, send the returned id to the other side, and both sides talk over the same event.. Used to open the bridge for that case: 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`](https://create.roblox.com/docs/reference/engine/classes/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](https://create.roblox.com/docs/luau/tuples):

| Position | Type             | Description          |
| -------- | ---------------- | -------------------- |
| 1        | `number?`        | The channel id.      |
| 2        | `BindableEvent?` | The channel's event. |

Both values are `nil` if the channel could not be opened.

## Example

The main thread opens a channel and starts a `run_on_actor`  with the id. The worker thread fires a message back, and the main thread catches it on `.Event:Connect`.

<CodeGroup>
  ```luau Example 1 theme={null}
  local create_comm_channel = create_comm_channel()local create_comm_channel = create_comm_channel()
  ```

  ```luau Example 2 theme={null}
  -- main thread
  local id, channel = create_comm_channel()

  channel.Event:Connect(function(payload)
      print(`worker said: {payload}`)
  end)

  -- hand the id to the worker, e.g. as a run_on_actor argument
  run_on_actor(actor, workerScript, id)
  ```
</CodeGroup>

<Tip>
  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.
</Tip>
