Syntax
getactorfromthread(thread: thread): Instance | nilAliases
getactorfromstateArguments
| Name | Type | Description |
|---|---|---|
thread | thread | Luau thread whose thread data should be checked for an associated Actor weak reference. |
Returns
| Name | Type | Description |
|---|---|---|
actor | Instance | nil | Actor Instance resolved from the thread's the associated Actor weak reference, or nil when no valid actor reference is present. |
Description
Returns the Actor Instance associated with a Luau thread. The first argument must be a thread. The function reads the thread's thread data, requires a Actor reference and a positive container count, then reads the associated Actor. If the actor weak reference is valid, it is pushed as an Instance; otherwise the function returns nil.
Call it with 1 parameter(s): thread. The argument table explains which values are required and which ones only refine the behavior.
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 a Luau thread, when that thread has a valid actor reference.
for _, thread in ipairs(getactorthreads()) do
local actor = getactorfromthread(thread)
print(actor)
end