writefile

Creates or replaces a file in Workspace.

Syntax

Signature
writefile(Path: string, Data: string) -> ()

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
PathstringPath relative to the sandboxed Workspace.
DatastringInput bytes; binary strings are supported.

Returns

TypeDescription
()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)