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.

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

Parameters

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

Example
Luau
local settings = { theme = "dark", volume = 0.8 }
writefile("settings.json", json.encode(settings))
print("Saved settings")
Kawaii documentation