getscriptfromthread Synchronous
Find the script Instance associated with a coroutine. Use it when you have a thread reference and need its script origin.
Luau
getscriptfromthread(target: thread) -> ScriptInstance?Parameters
| Parameter | Type | Description |
|---|---|---|
target | thread | Coroutine to inspect. |
Returns
ScriptInstance?A script Instance when the thread has one, or nil otherwise.
Usage notes
An executor-created coroutine may not belong to any Script Instance.
Example
Luau
local owner = getscriptfromthread(coroutine.running())
print(owner and owner.Name or "No script for this thread")