writefile Synchronous
writefileasync
Save a string to a workspace file, creating it when necessary. Writing an existing file replaces its contents, which suits settings snapshots and generated exports.
Luau
writefile(path: string, contents: string) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Workspace-relative destination path. |
contents | string | Text or binary bytes to store. |
Returns
()No values.
Usage notes
Serialize Luau tables before writing them. Use appendfile when the old contents need to remain.
Differences from Volt
Volt documents access through explicitly created workspace symlinks. Kawaii rejects symlinks in workspace paths; all workspace operations remain subject to its path containment checks.
Example
Luau
local settings = { theme = "dark", volume = 0.8 }
writefile("settings.json", json.encode(settings))
print("Saved settings")