Skip to content
File systemOverview

dofile

Local script-execution API.

Details#

Loads and executes a workspace-relative script file. Unlike loadfile, this starts the chunk immediately; errors can arise while reading, compiling or running it.

Examples#

Example

Luau
local path = "docs-dofile-example.luau"
assert(not isfile(path), "Example file already exists")
writefile(path, "print(42)")
local ok, err = pcall(dofile, path)
delfile(path)
if not ok then warn(err) end