ReferenceFilesystem

loadfileasync

Compiles a workspace file without executing it. Returns the compiled function, or nil and a compilation error.

Syntax

loadfileasync(path: string): (function?, string?)

Parameters

ParameterTypeDescription
pathstringWorkspace-relative file.

Returns

TypeDescription
function?, string?Compiled closure or compilation error.

Description

Use loadfile for the full path, error and return contract. The Async spelling does not grant access outside the workspace and does not mean that a callback argument is required. It suspends the calling thread once before running, so a thread started with task.spawn is still alive when task.spawn returns.

Example

local result = loadfileasync("example.luau")
print(result)

These are Game executor contracts. Check build requirements and session lifetimes before using them.