Actors

getcurrentactor

Returns the Actor Instance associated with the current Luau thread.

Syntax

getcurrentactor(): Instance | nil
Aliases get_current_actor

Returns

NameTypeDescription
actorInstance | nilActor Instance resolved from the current thread's the associated Actor weak reference, or nil when no valid actor reference is present.

Description

Returns the Actor Instance associated with the current Luau thread. The function takes no arguments. It resolves the current Luau thread with the same lookup used by getactorfromthread: the thread data must exist, Actor reference must exist, reference count must be greater than 0, and the associated Actor must hold a non-expired weak reference. If no valid actor reference is present, the function returns nil.

Call it without parameters. The function reads the needed context from the current runtime state.

It returns actor (Instance | nil). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Resolve the Actor Instance associated with the current Luau thread.

local actor = getcurrentactor()

print(actor)