> ## 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.

# getgenv

Returns the executor's global environment - a shared table across all scripts in the same Roblox session.
<span className="subtext">Userscripts can add values to it, but they're gone the moment you leave a Roblox game.</span>

```luau theme={null}
getgenv(): table
```

## Returns

| Top-level              | What's in it                                                                                                                                                                        |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Seliware's environment | Seliware's functions and libraries (`getgc`, `hookfunction`, the `WebSocket` library, and the rest), including whatever a user's script writes there - bools, numbers, tables, etc. |
| Roblox globals         | Reachable through the env's raw metatable - `print`, `task`, and everything else a normal Roblox script sees.                                                                       |

<span className="subtext">Reaching Roblox globals through `getgenv()` (like `getgenv().print`) works, but there is no reason to - they are already in scope, so call `print`, `task`, and the rest directly. The one exception is `require`: use `getrenv().require` for the game's copy, covered on the `getrenv` page.</span>

## Example

In a Roblox game, stop your script from running twice - executing it again stacks hooks and breaks what the first run set up.

<CodeGroup>
  ```luau Example 1 theme={null}
  local env = getgenv()
  ```

  ```luau Example 2 theme={null}
  if getgenv().myScriptLoaded then
      return
  end

  getgenv().myScriptLoaded = true

  print(`script has executed for the first time this session`)
  -- ... rest of your script
  ```
</CodeGroup>

<Tip>
  Use this table to share variables and utility modules between scripts.
</Tip>
