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.
Summary
Properties
Properties inherited from Model- read parallel
Sets the level of detail on the model for experiences with instance streaming enabled.
- read parallel
Controls the model streaming behavior on Models when instance streaming is enabled.
- read parallel
Points to the primary part of the Model.
Editor-only property used to scale the model around its pivot. Setting this property will move the scale as though Model/ScaleTo was called on it.
- not replicatedread parallel
Determines where the pivot of a Model which does not have a set Model.PrimaryPart is located.
- not replicatednot scriptableread parallel
Methods
- write parallel
Binds a Luau callback to a message with the specified topic.
- write parallel
Binds a Luau callback to a message with the specified topic.
- write parallel
Sends a message to an Actor.
Sets this model to be persistent for the specified player. Model.ModelStreamingMode must be set to PersistentPerPlayer for behavior to be changed as a result of addition.
Returns a description of a volume that contains all parts of a Model.
Returns the size of the smallest bounding box that contains all of the BaseParts in the Model, aligned with the Model.PrimaryPart if it is set.
Returns all the Player objects that this model object is persistent for. Behavior varies based on whether this method is called from a Script or a LocalScript.
Returns the canonical scale of the model, which defaults to 1 for newly created models and will change as it is scaled via Model/ScaleTo.
Moves the PrimaryPart to the given position. If a primary part has not been specified, the root part of the model will be used.
Makes this model no longer persistent for specified player. Model.ModelStreamingMode must be set to PersistentPerPlayer for behavior to be changed as a result of removal.
Sets the scale factor of the model, adjusting the sizing and location of all descendant Instances such that they have that scale factor relative to their initial sizes and locations when scale factor was 1.
Shifts a Model by the given Vector3 offset, preserving the model's orientation. If another BasePart or Terrain already exists at the new position then the Model will overlap said object.
Gets the pivot of a PVInstance.
Transforms the PVInstance along with all of its descendant PVInstances such that the pivot is now located at the specified CFrame.
Properties
Methods
BindToMessage
This method is used to bind a Luau callback to a message with the specified topic. When a message is sent (using Actor/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.
local actor = script:GetActor()
-- Print out a message when a greeting message is sent to the Actor
-- this script is a descendant of.
local connection = actor:BindToMessage("Greeting", function(message)
print("Received Greeting Message:", message)
end)
Parameters
Returns
This connection object may be used to disconnect the Luau callback from receiving messages.
BindToMessageParallel
This method is used to bind a Luau callback to a message with the specified topic. When a message is sent (using Actor/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.
local actor = script:GetActor()
-- Print out a message when a greeting message is sent to the Actor
-- this script is a descendant of.
local connection = actor:BindToMessageParallel("Greeting", function(message)
print("Received Greeting Message:", message)
end)
Parameters
Returns
This connection object may be used to disconnect the Luau callback from receiving messages.
SendMessage
Sends a message to an Actor. Messages are sent asynchronously, so the sender will not block or yield when calling the Actor/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 Actor/BindToMessage for details on receiving a message sent using Actor/SendMessage.
-- Assume `actor` is a local variable referring to an Actor instanceactor:SendMessage("Greeting", "Hello World")
Parameters
The topic used to identify the message being sent.
The contents of the message to send to the Actor.