dofile Asynchronous
dofileasyncrunfile
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.
Luau
dofile(path: string) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Workspace-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
Luau
local path = "dofile-example.luau"
writefile(path, [[print("Hello from a workspace script")]])
dofile(path)
delfile(path)