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

# getmenv

> Returns the environment table associated with a ModuleScript. The argument must be a ModuleScript object. Invalid objects raise "Invalid Instance", non-ModuleScript objects raise "ModuleScript expected", and ModuleScripts without an available thread raise "invalid thread". The function does not accept Script or LocalScript; use getsenv for those cases.

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

  ## Arguments

  <ParamField path={"moduleScript"} type={"userdata"} required>
    ModuleScript object whose environment table should be returned.
  </ParamField>

  ## Retours

  <ResponseField name={"environment"} type={"table"}>
    Environment table associated with the ModuleScript.
  </ResponseField>

  ## Exemple

  Read the environment table associated with a ModuleScript.

  ```lua theme={null}
  local moduleScript

  for _, descendant in ipairs(game:GetDescendants()) do
      if descendant:IsA("ModuleScript") then
          moduleScript = descendant
          break
      end
  end

  if moduleScript then
      local environment = getmenv(moduleScript)
      print(environment)
  end
  ```
</div>
