---
title: "gettenv"
description: "Returns the specified thread's global environment."
---

```lua
gettenv(thread: thread): table?
```

---

## Aliases

None.

---

## Arguments

<ParamField body="thread" type="thread" required>
  The coroutine whose environment, script association, or stack is inspected.
</ParamField>

---

## Returns

<ResponseField name="environment" type="table?">
  The thread's global environment, or nil if it cannot be resolved.
</ResponseField>

Returns nil if the native thread cannot be resolved.

---

## Example

```lua
local thread = coroutine.create(function() end)
print(type(gettenv(thread)))
```
