dofile Asynchronous

  • dofileasync
  • runfile

Load and run a Luau file from the workspace in one call. Choose it when the file is a script to execute, not data to parse.

Syntax
Luau
dofile(path: string) -> ()

Parameters

Function parameters
ParameterTypeDescription
pathstringWorkspace-relative path of the Luau file.

Returns

()

No values; any return values from the loaded script are discarded.

Usage notes

A missing file raises. If compilation fails, the error from loadfile is raised by dofile.

Example

Example
Luau
local path = "dofile-example.luau"
writefile(path, [[print("Hello from a workspace script")]])
dofile(path)
delfile(path)
Kawaii documentation