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
726LevelOfDetail: ModelLevelOfDetail
726ModelStreamingMode: ModelStreamingMode
726PrimaryPart: BasePart
726Scale: float
726WorldPivot: CFrame
573AddPersistentPlayer(playerInstance: Player = Player): null
573BreakJoints(): null
607GetBoundingBox(): (CFrame, Vector3)
462GetExtentsSize(): Vector3
726GetModelCFrame(): CFrame
726GetModelSize(): Vector3
648GetPersistentPlayers(): Instances
726GetPrimaryPartCFrame(): CFrame
562GetScale(): float
573MakeJoints(): null
573MoveTo(position: Vector3): null
573RemovePersistentPlayer(playerInstance: Player = Player): null
726ResetOrientationToIdentity(): null
573ScaleTo(newScaleFactor: float): null
726SetIdentityOrientation(): null
726SetPrimaryPartCFrame(cframe: CFrame): null
573TranslateBy(delta: Vector3): null
726breakJoints(): null
726makeJoints(): null
726move(location: Vector3): null
726moveTo(location: Vector3): null
inherited from PVInstance
726Origin: CFrame
726Pivot Offset: CFrame
576GetPivot(): CFrame
573PivotTo(targetCFrame: CFrame): null
inherited from Instance
726Archivable: bool
726Capabilities: SecurityCapabilities
726IsInSandbox: bool
726Name: string
726Parent: Instance
726PredictionMode: PredictionMode
726Sandboxed: bool
726UniqueId: 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
726children(): Instances
726clone(): Instance
726destroy(): null
726findFirstChild(name: string, recursive: bool = false): Instance
726getChildren(): Instances
726isDescendantOf(ancestor: Instance): bool
726remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
726childAdded(child: Instance)
inherited from Object
726ClassName: string
726className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
726isA(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