getscriptfromthread
Notes on getscriptfromthread
This function should return the script associated with the thread, regardless of any mutations made to itself or its environment.
This also includes threads whose script global variable is set to nil or reassigned - i.e. getscriptfromthread should still return said script.
getscriptfromthread should use the script reference stored on the thread itself, not the thread environment's script value. This reference is weak, so it should not keep the script alive.
Returns nil when no script is associated
If the given thread has no associated Script, LocalScript, or ModuleScript, this function should return nil.
This includes executor-created threads. If the thread's weak script reference no longer points to a live script, such as after the script is garbage collected, this function should also return nil.
getscriptfromthread returns the Script, LocalScript, or ModuleScript associated with a given Luau thread.
Parameters
| Parameter | Description |
|---|---|
thread |
The Luau thread whose associated script should be retrieved. |