Filesystem APIs

NOTE: All filesystem APIs are sandboxed to the workspace folder in your Synapse installation. Attempting to access files outside of this folder will result in an error.

Functions

readfile

string readfile(path: string)

Reads a file from the workspace folder.

readfileasync

string readfileasync(path: string) [yields]

Reads a file from the workspace folder asynchronously.

writefile

void writefile(path: string, contents: string)

Writes to a file in the workspace folder.

writefileasync

void writefileasync(path: string, contents: string) [yields]

Writes to a file in the workspace folder asynchronously.

appendfile

void appendfile(path: string, contents: string)

Appends to a file in the workspace folder.

appendfileasync

void appendfileasync(path: string, contents: string) [yields]

Appends to a file in the workspace folder asynchronously.

loadfile

(function?, string?) loadfile(path: string, contents: string)

Equivalent to loadstring(readfile(path)).

loadfileasync

(function?, string?) loadfileasync(path: string, contents: string) [yields]

Equivalent to loadstring(readfileasync(path)).

listfiles

table listfiles(folder?: string)

Returns an array of file names belonging to folder.

isfile

bool isfile(path: string)

Returns true if path refers to a file.

isfolder

bool isfolder(path: string)

Returns true if path refers to a folder.

makefolder

bool makefolder(path: string)

Recursively creates directories. Returns true on success.

delfolder

void delfolder(path: string)

Deletes a folder.

delfile

void delfile(path: string)

Deletes a file.

getsynasset

string getsynasset(path: string)

Returns a Content string that can be used with GUI elements, sounds, meshes, and etc. to refer to an asset in the workspace folder.

Note: Certain assets only work with certain file types. For example, VideoFrames only work with .webm encoded videos.

saveinstance

bool saveinstance(instance: Instance | table, options?: table) [yields]

Saves an instance in binary (.rbxl or .rbxm) format. The following options can be passed:

OptionDescriptionDefault
FileNameOutput fileVaries
IgnoreArchivableIgnores the Archivable propertyfalse
SavePlayerCharactersIncludes player characters (.rbxl only)false
SavePlayersIncludes Player objects and their descendants (.rbxl only)false
DisableCompressionDisables compression in the binary outputfalse
DecompileStarts a batch decompiler job for all relevant scripts and includes the resultsfalse
DecompileJoblessIncludes already decompiled code in the output. No new scripts are decompiled.false
SaveNonCreatableIncludes non-serializable instances as Folder objectsfalse
NilInstancesIncludes nil instances (.rbxl only)false
CopyToClipboardIf true, copies the result to clipboard instead of writing to diskfalse
IgnoreListA list of instances (and their descendants) to ignore{}
DecompileOptionsSee documentation for decompile{}

If the Decompile option is enabled, saveinstance returns true when the job completes successfully or false if cancelled by the user.

saveplace

bool saveplace(options?: table) [yields]

Equivalent to saveinstance(game, options).

Classes