Decompiling scripts

Read client script and Luau function bytecode through the Internal Menu or decompile().

Roblox sends client-side scripts to your PC as compiled Luau bytecode. decompile turns that bytecode back into source you can read, search & learn from.

One script

In the Internal Menu, choose Decompile for a script in Scripts or right-click a script in Explorer and choose Decompile. The result opens in a source window with Copy Code and Open new Tab buttons.

You can also call decompile from a script. It returns the recovered source as a string, which you can write to the workspace:

decompile-one.luau
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local module = ReplicatedStorage:FindFirstChildWhichIsA("ModuleScript", true)
if module then
writefile(module.Name .. ".luau", decompile(module))
end

Many scripts

A loop decompiles a whole folder of the game into a folder of your workspace.

dump-player-scripts.luau
local Players = game:GetService("Players")
local playerScripts = Players.LocalPlayer:WaitForChild("PlayerScripts")
makefolder("decompiled")
for _, object in playerScripts:GetDescendants() do
if object:IsA("LocalScript") or object:IsA("ModuleScript") then
local source = decompile(object)
local name = object:GetFullName():gsub("[^%w%.%-]", "_")
writefile("decompiled/" .. name .. ".luau", source)
end
end

What to expect

decompile yields while it works, then returns a string:

  • On success, the reconstructed Luau source.
  • On failure, an error. Use pcall when you need to handle a timeout or unavailable bytecode and continue.
  • Bytecode works too. Pass the string from getscriptbytecode instead of a script.
  • Luau functions work too. Pass a Luau function directly, or choose Decompile function from a supported function or stack-frame context menu in the Internal Menu.
local ok, result = pcall(decompile, function(value)
return value * 2
end)
if ok then
print(result)
else
warn(result)
end

Bytecode keeps the structure of a program, but not everything the author wrote. Comments & type annotations are never recovered, because they don't exist in bytecode.

What can't be decompiled

  • Server scripts. A Script that runs on the server never reaches your PC. There's no bytecode to decompile.
  • Anything that stays on the server. Scripts in ServerScriptService & ServerStorage are never replicated to clients.
  • Native C functions. These contain native code rather than Luau bytecode.

A whole place

saveinstance() saves the place you're in as a Roblox place file and decompiles its scripts on the way. Pass { Decompile = false } to skip the decompiling & save faster.

SaveInstance's ScriptTimeout limits how long each script decompilation waits, while DecompileTimeout limits the decompilation batch after bytecode capture. Both use seconds; DecompileTimeout does not limit the whole export. A timed-out native job can finish in a bounded background slot while the export continues. See SaveInstance options for defaults and failure handling.