> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# gettenv

> Returns the environment table stored on a Luau thread. getstateenv is an alias.

<div className="real-function-page">
  ```lua theme={null}
  gettenv(thread: thread): table
  ```

  ## Aliases

  * `getstateenv`

  ## Arguments

  <ParamField path={"thread"} type={"thread"} required>
    Luau thread whose environment table is returned.
  </ParamField>

  ## Returns

  <ResponseField name={"environment"} type={"table"}>
    Environment table for the supplied thread.
  </ResponseField>

  ## Example

  Read the environment table stored on a Luau thread.

  ```lua theme={null}
  local thread = coroutine.create(function()
  end)

  local env = gettenv(thread)
  print(type(env))

  local aliasEnv = getstateenv(thread)
  print(type(aliasEnv))
  ```
</div>
