World Executor · Roblox VM

Scripts

Discover running scripts and modules, decompile and hash bytecode, load Luau source, and link scripts to their threads and environments.

Overview

This chapter covers finding the code a game is running, reading what it compiled to, and loading code of your own.

getrunningscripts and getscripts enumerate what is live; getsenv opens a script's own environment so you can read and rewrite the locals it declared; getscriptbytecode and getscripthash give you the compiled form, which is what a decompiler works from.

Reaching into a running script
for _, script in ipairs(getrunningscripts()) do
    if script.Name == "AntiCheat" then
        -- Read what the script itself declared.
        local env = getsenv(script)
        print(env.enabled)
        env.enabled = false

        -- Or work from the compiled form.
        print(getscripthash(script))
    end
end

getcallingscript identifies your caller

Inside a hook, getcallingscript() returns the script that made the call. It is the cleanest way to filter a noisy hook down to one source.

Running scripts

Threads and environments

Bytecode

Loading

Four ways in, differing in where the source comes from: loadstring from a string, loadfile from the workspace, dofile loads and runs in one step, runfile the same with the workspace path rules applied.