Skip to content

Class · inherits Model

Actor

Official docs ↗

An Actor is a container for code that can be safely split into its own thread.

About Actor

An Actor is a container for code that can be safely split into its own thread using task.desynchronize. It should also contain the instances used by its scripts.

To learn more about using multiple Actors to optimize script performance, see Parallel Luau.

Notes

  • Each Actor runs in its own Luau VM. ModuleScripts required by an Actor are not shared or cached across Actors or with the main thread. Each VM executes its own copy of the module, so module-level state is isolated per Actor. Design accordingly if your modules hold state you intend to share.
  • script:GetActor() returns nil when called from a ModuleScript unless the ModuleScript is a descendant of the Actor. ModuleScripts stored elsewhere (for example, ReplicatedStorage) and required by an Actor are not considered descendants of the Actor.

Methods 3

  • BindToMessage(topic: string, function: Function) → RBXScriptConnectionBinds a Luau callback to a message with the specified topic.

    This method is used to bind a Luau callback to a message with the specified topic. When a message is sent (using SendMessage()) to the topic specified the provided callback will be called in a serial execution context.

    Multiple Luau callbacks may be bound to a single actor and even to a single message topic.

    Note: Only the scripts which are descendants of an Actor may bind to its messages.

  • BindToMessageParallel(topic: string, function: Function) → RBXScriptConnectionBinds a Luau callback to a message with the specified topic.

    This method is used to bind a Luau callback to a message with the specified topic. When a message is sent (using SendMessage()) to the topic specified the provided callback will be called in a parallel execution context.

    Multiple Luau callbacks may be bound to a single actor and even to a single message topic.

    Note: Only the scripts which are descendants of an Actor may bind to its messages.

  • SendMessage(topic: string, message: Tuple) → ()Sends a message to an Actor.

    Sends a message to an Actor. Messages are sent asynchronously, so the sender will not block or yield when calling the SendMessage() method.

    Since a single Actor may receive different kinds of messages, a topic parameter is used to distinguish between various kinds of messages.

    See BindToMessage() for details on receiving a message sent using SendMessage().

    Note that message arguments are passed by copy across Luau VM boundaries, not by reference. Sending large tables incurs a full copy on each call. Functions are bound to a specific VM and cannot be passed in messages.

Actor also has every member of Model. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.