writefileasync Asynchronous
Write a workspace file on a background thread, replacing any existing contents. The script continues once the file is written.
Luau
writefileasync(path: string, contents: string) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Workspace-relative destination path. |
contents | string | Bytes to write. |
Returns
()No values.
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.
Missing parent folders are handled the same way as writefile.
Example
Luau
local settings = json.encode({ volume = 0.5 })
writefileasync("async-settings.json", settings)
print(readfile("async-settings.json"))
delfile("async-settings.json")