VINDICTA
Filesystem · Function
Bunni.fun
ChocoSploit
Cryptic
Potassium
Seliware
SirHurt
Solara
Velocity
Volcano
Volt
Wave
Xeno

writefile

Writes data to a file, overwriting any existing content.

function writefile(path: string, data: string): ()

Synopsis

How it works

Writes a string to a file in the executor’s workspace directory. Uses CreateFileA with CREATE_ALWAYS disposition:
CreateFileA(path, GENERIC_WRITE, 0, NULL,
            CREATE_ALWAYS,  // overwrite if exists, create if not
            FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(handle, data, dataLen, &bytesWritten, NULL);
CloseHandle(handle);
The CREATE_ALWAYS disposition means the file is truncated to zero length before writing if it already exists. Supports binary data since Lua strings can contain any byte value.

Common uses

Saving configuration, logging data, exporting game assets, or caching state between sessions. Parent directories must exist — use makefolder() first if needed. Note: there is no atomic write guarantee — if the process crashes mid-write, the file may be truncated.

Usage

Save player data
writefile("playerdata.json", game:GetService("HttpService"):JSONEncode({coins=100}))

Parameters

path string
Path to the file.
data string
The content to write.