Syntax
decompile(script: userdata): string | nilArguments
| Name | Type | Description |
|---|---|---|
script | userdata | Script object to decompile. Supported ClassName values are ModuleScript, LocalScript, CoreScript, and Script with RunContext Client. |
Returns
| Name | Type | Description |
|---|---|---|
source | string | nil | Decompiler output string, caught decompiler exception text, or nil when no usable embedded bytecode is available. |
Description
Decompiles a Roblox script and returns the generated source text when bytecode is available. The argument must be a supported script Instance. If usable bytecode is not available, the function returns nil.
Call it with 1 parameter(s): script. The argument table explains which values are required and which ones only refine the behavior.
It returns source (string | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Decompile a supported Roblox script Instance. To decompile a whole game, iterate its descendants or use a saveinstance workflow.
local targetScript
for _, descendant in ipairs(game:GetDescendants()) do
if descendant:IsA("LuaSourceContainer") then
targetScript = descendant
break
end
end
if targetScript then
local source = decompile(targetScript)
if source then
print(source)
end
end