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:
| Option | Description | Default |
|---|---|---|
| FileName | Output file | Varies |
| IgnoreArchivable | Ignores the Archivable property | false |
| SavePlayerCharacters | Includes player characters (.rbxl only) | false |
| SavePlayers | Includes Player objects and their descendants (.rbxl only) | false |
| DisableCompression | Disables compression in the binary output | false |
| Decompile | Starts a batch decompiler job for all relevant scripts and includes the results | false |
| DecompileJobless | Includes already decompiled code in the output. No new scripts are decompiled. | false |
| SaveNonCreatable | Includes non-serializable instances as Folder objects | false |
| NilInstances | Includes nil instances (.rbxl only) | false |
| CopyToClipboard | If true, copies the result to clipboard instead of writing to disk | false |
| IgnoreList | A list of instances (and their descendants) to ignore | {} |
| DecompileOptions | See 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).