VINDICTA
Filesystem · Function
Bunni.fun
ChocoSploit
Cryptic
Potassium
Seliware
SirHurt
Solara
Velocity
Volcano
Volt
Wave
Xeno

dofile

Loads and executes a file on a new thread.

function dofile(path: string): ()

Synopsis

How it works

Reads a file from the workspace, compiles it with loadstring, and immediately executes the resulting closureClosureA function value that captures its lexical environment. In Luau, closures come in two types: LClosure (Luau bytecode + Proto + upvalues) and CClosure (native C function pointer + upvalues).. Equivalent to:
local fn = loadstring(readfile(path))
return fn()
Unlike loadfile, this executes the code immediately rather than returning a callable function. The environment is the caller's global environmentGlobal environment (genv)The executor's global environment table — the _G-equivalent for executor-loaded scripts. Functions set here (via getgenv()) are accessible from any executor script but invisible to game scripts.. Throws on file-not-found or compilation errors.

Usage

Run a script file
dofile("scripts/autoexec.lua")

Parameters

path string
Path to the file to execute.