Syntax
gettenv(thread: thread): tableAliases
getstateenvArguments
| Name | Type | Description |
|---|---|---|
thread | thread | Luau thread whose environment table is returned. |
Returns
| Name | Type | Description |
|---|---|---|
environment | table | Environment table for the supplied thread. |
Description
Returns the environment table stored on a Luau thread. getstateenv is an alias.
Call it with 1 parameter(s): thread. The argument table explains which values are required and which ones only refine the behavior.
It returns environment (table). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Read the environment table stored on a Luau thread.
local thread = coroutine.create(function()
end)
local env = gettenv(thread)
print(type(env))
local aliasEnv = getstateenv(thread)
print(type(aliasEnv))