writefileasync Asynchronous

Write a workspace file on a background thread, replacing any existing contents. The script continues once the file is written.

Syntax
Luau
writefileasync(path: string, contents: string) -> ()

Parameters

Function parameters
ParameterTypeDescription
pathstringWorkspace-relative destination path.
contentsstringBytes 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

Example
Luau
local settings = json.encode({ volume = 0.5 })
writefileasync("async-settings.json", settings)
print(readfile("async-settings.json"))
delfile("async-settings.json")