> For the complete documentation index, see [llms.txt](https://duckys-playground.gitbook.io/wave/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://duckys-playground.gitbook.io/wave/libraries/actors.md).

# Actors

{% hint style="info" %}
Actors Library is Premium only!
{% endhint %}

### Create Communication Channel

{% code lineNumbers="true" %}

```typescript
<any> create_comm_channel(<string channelName>)
```

{% endcode %}

* Creates a communication channel for sending and receiving messages.

***

### Get Actors

<pre class="language-typescript" data-line-numbers><code class="lang-typescript"><strong>&#x3C;string> getactors(&#x3C;void>)
</strong></code></pre>

* Returns all the actors in the game, example above will return `0` if there are no actors in the game.

> Alternative: `get_actors`

***

### Get Actor From Thread

{% code lineNumbers="true" %}

```typescript
<any> get_actor_from_thread(<thread thrd>)
```

{% endcode %}

* Returns the actor (script or environment) associated with `thrd`.

> Alternative: `getactorfromthread`, `getthreadactor`, `get_thread_actor`

***

### Get Communication Channel

{% code lineNumbers="true" %}

```typescript
<any> get_comm_channel(<string channelName>)
```

{% endcode %}

* Retrieves an existing communication channel by `channelName`.

***

### Get Current Actor

```typescript
<string> get_current_actor(<void>)
```

* Returns the actor instance of the current running thread.

> Alternative: `getcurrentactor`

***

### Get Deleted Actors

```typescript
<string> getdeletedactors(<void>)
```

* Checks actor threads specifically connected to an expired actor instance.&#x20;

> Note: This function does not return the actor instance directly. Instead, it returns a lightuserdata that can be passed to `run_on_actor`.

> Alternative: `get_deleted_actors`

***

### Is Parallel

{% code lineNumbers="true" %}

```typescript
<string> is_parallel(<void>)
```

{% endcode %}

* Returns if the thread is parallel or not.

***

### Run On Actor

<pre class="language-typescript" data-line-numbers><code class="lang-typescript"><strong>&#x3C;string> run_on_actor(&#x3C;ActorState>, &#x3C;Script>)
</strong></code></pre>

* Will run the script on an actor state.

{% code lineNumbers="true" %}

```lua
local id, channel = create_comm_channel()
channel.Event:Connect(print) -- .Event returns channel, so we are connecting directly to channel

run_on_actor(Instance.new("Actor"), [[
local s = get_comm_channel(...)
s:Fire("hello from actor")
]], id)
```

{% endcode %}

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://duckys-playground.gitbook.io/wave/libraries/actors.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
