Reads a file and compiles it as Luau, returning the function. On a compile error it returns nil and the message, the same shape as loadstring.

Parameters

string
required
The file to compile.

Returns

function or nil
The compiled function, or nil with an error.

Example

Errors

  • dofile: compile and run in one step.