File systemOverviewNew · 0.744
loadfileasync
Describe asynchronous preparation of a local script file.
Details#
Reads and compiles a workspace script asynchronously, yielding the calling thread. Optional chunkName defaults to @file. Returns a function, or nil plus an error for reading or compilation failure; invalid workspace paths raise an error. It does not run the chunk.
Examples#
Example
local path = "docs-async-example.luau"
assert(not isfile(path), "Example file already exists")
writefile(path, "return 42")
local chunk, err = loadfileasync(path, "docs-example")
delfile(path)
if chunk then print(chunk()) else warn(err) end