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

# debug.getsafeenv

Returns the safe environment table of the specified function.

```luau theme={null}
debug.getsafeenv(func: function): table
```

## Parameters

| Parameter | Type       | Description                     |
| --------- | ---------- | ------------------------------- |
| `func`    | `function` | The target function to inspect. |

## Returns

`table` - The safe environment table.

## Example

<CodeGroup>
  ```luau Example 1 theme={null}
  local env = debug.getsafeenv(print)
  print("Safe env type: ", type(env))
  ```

  ```luau Example 2 theme={null}
  local env = debug.getsafeenv(function() end)
  assert(env == getgenv(), "Local functions should share executor environment by default")
  ```
</CodeGroup>

<Tip>
  Safe environments isolate script contexts to prevent access violations.
</Tip>
