readfileasync Asynchronous
Read a workspace file without blocking the game while the bytes load. Use it for larger files where readfile would stall a frame.
Luau
readfileasync(path: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
path | string | Workspace-relative path of the file to read. |
Returns
stringThe complete file contents as a binary-safe string.
Usage notes
The file work runs on a background thread, and the call always yields at least one frame, even for a small file. Filesystem failures raise in the calling thread.
Call it from a thread that may yield, such as a script body or a task.spawn function.
Example
Luau
writefile("async-read.txt", "Loaded in the background")
local contents = readfileasync("async-read.txt")
print(contents)
delfile("async-read.txt")