Get a script's main closure (LocalScript/ModuleScript)
get-script-closureRetrieve a script's compiled main function from a Luau expression without executing it, enabling static bytecode analysis of protected or unexecuted scripts.
Instructions
Resolve a Luau expression to a LocalScript or ModuleScript Instance and retrieve its compiled main function via getscriptclosure (falling back to getscriptfunction if the executor exposes that name instead). The returned closure is the script's top-level chunk WITHOUT running it — so you can statically analyse a script's bytecode (its constants, upvalues, and nested protos) even when it is protected, never executed, or you don't want its side effects. This is the entry point for static RE of a single script: feed the resulting function into get-closure-constants / get-closure-upvalues / get-closure-protos to drill in. Requires the executor's getscriptclosure (or getscriptfunction); if neither exists a clean { error } is returned. Returns { Script, Function:__fnInfo, ConstantCount, UpvalueCount } or { error }. Signature: { scriptPath: string, threadContext: number? }. Phase: orchestrate; cost=medium; idempotency=read-only. Requires: active-client, resolved-target. Capabilities: debug closure primitives. 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 |
|---|---|---|---|
| scriptPath | Yes | Luau expression resolving to a LocalScript or ModuleScript Instance, e.g. 'game.Players.LocalPlayer.PlayerScripts.Main', 'game.ReplicatedStorage.Modules.Settings', or 'game:GetService("ReplicatedFirst").Loader'. Evaluated as `return <scriptPath>`; the value must be an Instance. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |