Class · inherits Model
Actor
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
Actorruns in its own Luau VM.ModuleScriptsrequired by anActorare not shared or cached acrossActorsor with the main thread. Each VM executes its own copy of the module, so module-level state is isolated perActor. Design accordingly if your modules hold state you intend to share. script:GetActor()returnsnilwhen called from aModuleScriptunless theModuleScriptis a descendant of theActor.ModuleScriptsstored elsewhere (for example,ReplicatedStorage) and required by anActorare not considered descendants of theActor.
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
topicparameter is used to distinguish between various kinds of messages.See
BindToMessage()for details on receiving a message sent usingSendMessage().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.