Syntax
getscriptfromthread(thread: thread): Instance | nilArguments
| Name | Type | Description |
|---|---|---|
thread | thread | Luau thread whose associated Script Instance is returned. |
Returns
| Name | Type | Description |
|---|---|---|
script | Instance | nil | Associated Script Instance when available; otherwise nil. |
Description
Returns the Script Instance associated with a Luau thread, or nil when no valid script reference is available.
Call it with 1 parameter(s): thread. The argument table explains which values are required and which ones only refine the behavior.
It returns script (Instance | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Read the Script Instance stored on a Luau thread, if one is attached.
local thread = coroutine.create(function()
end)
local scriptInstance = getscriptfromthread(thread)
print(scriptInstance)