# Scripts

## getgc

```lua
<table<function | userdata | table>> getgc(<boolean?> includetables)
```

Returns a list of objects in the Luau garbage collector.

If `includeTables` is false, tables will not be included in the list.

***

## getgenv

```lua
<table<[string]: any>> getgenv()
```

Returns the custom global environment of the executor.

***

## gettenv

```lua
<table<[string]: any> gettenv(<thread> thread)
```

Returns the environment of `thread`.

***

## getreg

```lua
<table<function | thread>> getreg()
```

Returns the lua registry.

***

## getloadedmodules

```lua
<table<ModuleScript>> getloadedmodules()
```

Returns a list of ModuleScripts that have been loaded.

***

## getrenv

```lua
<table<[string]: any>> getrenv()
```

Returns the global environment of the game client. It can be used to access the global functions that LocalScripts and ModuleScripts use.

***

## getrunningscripts

```lua
<table<LocalScript | ModuleScript>> getrunningscripts()
```

Returns a list of scripts that are currently running.

***

## getscriptbytecode

```lua
<string> getscriptbytecode(<LocalScript | ModuleScript> script)
```

Returns the raw Luau bytecode of the given script.

***

## getscriptclosure

```lua
<function> getscriptclosure(<LocalScript | ModuleScript> script)
```

Generates a new closure using the bytecode of `script`.

***

## getscripthash

```lua
<string> getscripthash(<LocalScript | ModuleScript> script)
```

Returns a SHA384 hash of the script's bytecode.

***

## getscripts

```lua
<table<LocalScript | ModuleScript>> getscripts()
```

Returns a list of every script in the game.

***

## getsenv

```lua
<table<[string]: any>> getsenv(<LocalScript | ModuleScript> script)
```

Returns the global environment of the given script. It can be used to access variables and functions that are not defined as local.

***

## getthreadidentity

```lua
<number> getthreadidentity()
```

Returns the identity of the current thread.

***

## setthreadidentity

```lua
<nil> setthreadidentity(<number> identity)
```

Sets the current thread identity.

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://potassium.gitbook.io/api/environment/scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
