gettenv Synchronous
getstateenv
Get the environment table attached to a coroutine. Pass a thread when inspecting another coroutine, or omit it to check your own.
Luau
gettenv(target: thread?) -> Table?Parameters
| Parameter | Type | Description |
|---|---|---|
target | thread? | Optional coroutine; defaults to the caller. |
Returns
Table?That thread's environment table, or nil when it cannot be read in this VM.
Usage notes
A thread from a different Luau state cannot be inspected through this call.
Example
Luau
local current = coroutine.running()
local env = gettenv(current)
if env then
print("This thread has an environment table")
end