getscriptthread
Returns a thread associated with a client script or ModuleScript.
Syntax
getscriptthread(script: LocalScript | ModuleScript | Script) -> thread?Parameters
| Parameter | Type | Description |
|---|---|---|
script | LocalScript, ModuleScript, or client Script | Script whose thread should be found |
Returns
| Type | Description |
|---|---|
thread? | The associated thread, or nil when none is available |
Example
local runningScript = getrunningscripts()[1]
local thread = runningScript and getscriptthread(runningScript)
if thread then
print(coroutine.status(thread))
print(getscriptfromthread(thread) == runningScript) -- true
else
warn("No running script thread was available")
endRelated Functions
getscriptfromthread- Perform the reverse lookupgetrunningscripts- List running scripts