writefile
Creates or replaces a file in Workspace.
Syntax
Signature
writefile(Path: string, Data: string) -> ()Aliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
Path | string | Path relative to the sandboxed Workspace. |
Data | string | Input bytes; binary strings are supported. |
Returns
| Type | Description |
|---|---|
() | None. |
Notes
The write is limited to 16 MiB. Missing parent directories are created. Invalid paths, blocked file extensions, and write failures raise errors.
Example
Luau
local Path = "Examples/Settings.json"
local Settings = {Enabled = true, Volume = 0.5}
writefile(Path, json.encode(Settings, true))
local Saved = json.decode(readfile(Path))
print(Saved.Enabled, Saved.Volume)