Reference API Roblox

Engine API

Website

Related

Reference API Roblox

Actor

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

Member index 3

HistoryMember
570BindToMessage(topic: string, function: Function): RBXScriptConnection
570BindToMessageParallel(topic: string, function: Function): RBXScriptConnection
573SendMessage(topic: string, message: Tuple): null
inherited from Model
731LevelOfDetail: ModelLevelOfDetail
731ModelStreamingMode: ModelStreamingMode
731PrimaryPart: BasePart
731Scale: float
731WorldPivot: CFrame
573AddPersistentPlayer(playerInstance: Player = Player): null
573BreakJoints(): null
607GetBoundingBox(): (CFrame, Vector3)
462GetExtentsSize(): Vector3
731GetModelCFrame(): CFrame
731GetModelSize(): Vector3
648GetPersistentPlayers(): Instances
731GetPrimaryPartCFrame(): CFrame
562GetScale(): float
573MakeJoints(): null
573MoveTo(position: Vector3): null
573RemovePersistentPlayer(playerInstance: Player = Player): null
731ResetOrientationToIdentity(): null
573ScaleTo(newScaleFactor: float): null
731SetIdentityOrientation(): null
731SetPrimaryPartCFrame(cframe: CFrame): null
573TranslateBy(delta: Vector3): null
731breakJoints(): null
731makeJoints(): null
731move(location: Vector3): null
731moveTo(location: Vector3): null
inherited from PVInstance
731Origin: CFrame
731Pivot Offset: CFrame
576GetPivot(): CFrame
573PivotTo(targetCFrame: CFrame): null
inherited from Instance
731Archivable: bool
731Capabilities: SecurityCapabilities
731IsInSandbox: bool
731Name: string
731Parent: Instance
731PredictionMode: PredictionMode
731Sandboxed: bool
731UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
731children(): Instances
731clone(): Instance
731destroy(): null
731findFirstChild(name: string, recursive: bool = false): Instance
731getChildren(): Instances
731isDescendantOf(ancestor: Instance): bool
731remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
731childAdded(child: Instance)
inherited from Object
731ClassName: string
731className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
731isA(className: string): bool
647Changed(property: string)

Description

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.

History 9

Members 3

BindToMessage

Parameters (2)
topicstring
functionFunction
Returns (1)
RBXScriptConnection

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.

1
2
3
4
5
6
7
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)

History 2

BindToMessageParallel

Parameters (2)
topicstring
functionFunction
Returns (1)
RBXScriptConnection

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.

1
2
3
4
5
6
7
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)

History 2

SendMessage

Parameters (2)
topicstring
messageTuple
Returns (1)
null

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.

1
2
-- Assume `actor` is a local variable referring to an Actor instance
actor:SendMessage("Greeting", "Hello World")

History 3

Settings