getscriptfromthread
Returns the script a thread was started by.
Syntax
getscriptfromthread(thread: thread) -> LuaSourceContainer?
Also available as
get_script_from_thread
Parameters
| Parameter | Type | Description |
|---|---|---|
thread | thread | The thread to look up. |
Returns
| Type | Description |
|---|---|
LuaSourceContainer? | The script the thread belongs to, or nil. |
Description
Threads created by a script, including task.spawn and coroutine children, belong to that script. Threads from your own code return nil.
Example
for _, thread in getallthreads() do
local owner = getscriptfromthread(thread)
if owner then
print(owner:GetFullName())
end
end
These are Game executor contracts. Check build requirements and session lifetimes before using them.
