Dump a script's environment (getsenv)
get-script-envResolve a running LocalScript/ModuleScript path and dump its live _ENV via getsenv to discover globals, exposed locals, functions, and values for inspection or hooking.
Instructions
Resolve an instance path to a running LocalScript/ModuleScript and dump its script environment table via getsenv. This is the live _ENV of that script: its globals, every top-level local it exposed as a global, and the functions/values it defined. Use it to discover what a script holds (config flags, references, handler functions) so you can then inspect or hook them by reference (e.g. feed getsenv(script).someFunc into inspect-closure or hook-function). The script must be currently running for getsenv to succeed. Requires getsenv. Returns { Script, KeyCount, Truncated, Keys } (keysOnly) or { Script, KeyCount, Truncated, Entries } or { error }. Signature: { scriptPath: string, keysOnly: any?, maxKeys: any?, threadContext: number? }. Phase: orchestrate; cost=medium; idempotency=read-only. Requires: active-client, resolved-target. Produces: structured-observation. Safety: read-only. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxKeys | No | Maximum number of environment keys/entries to return before truncating (default 200). | |
| keysOnly | No | When true (default) return only the environment key names — cheap and safe. When false also serialize each value's type and a scalar/string preview via __encVal. | |
| scriptPath | Yes | Luau expression resolving to the LocalScript/ModuleScript instance, e.g. 'game.Players.LocalPlayer.PlayerScripts.Main' or 'game:GetService("ReplicatedStorage").Modules.Net'. Evaluated as `return <scriptPath>`; must yield a running script instance. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |