Reads the file at path and runs it as Luau code. Whatever the file sets - locals, globals, even _G - stays in the file.
path is workspace-relative. The file must contain valid Luau source (not bytecode). Use loadfile when you want to inspect the chunk or call it more than once - dofile always runs it exactly once and throws the return values away.
Parameters
Returns
void - anything the file returns is discarded.
Example
Save a script to a file, then run it:
Variables declared inside the file don’t leak into the calling environment. If you need to share state, write to a known table (e.g. getgenv().myVariable = ...) inside the file and read it back from the caller.