gettenv
Returns the globals table a thread runs with.
Syntax
gettenv(thread: thread?) -> table?
Also available as
get_tenv
Parameters
| Parameter | Type | Description |
|---|---|---|
thread | thread? | The thread to read. Defaults to the current thread. |
Returns
| Type | Description |
|---|---|
table? | The thread's globals table, or nil when the thread has none. |
Description
For a thread started by a game script this is that script's environment, the same table its code reads globals from. Combined with getscriptthread or getallthreads, it lets you see the variables a running script set with plain global assignments.
Example
local thread = getscriptthread(game.Players.LocalPlayer.PlayerScripts.ClientMain)
if thread then
local env = gettenv(thread)
print(env.script)
end
These are Game executor contracts. Check build requirements and session lifetimes before using them.
