Filesystem
Functions for reading, writing, and managing files. All file operations are sandboxed to the executor's workspace folder.
WARNING
All paths are relative to the workspace folder. You cannot access files outside of it.
readfile
Returns the contents of a file as a string.
readfile(path: string) -> string| Parameter | Type | Description |
|---|---|---|
path | string | Relative path to the file |
Example
local content = readfile("mydata.txt")
print(content)writefile
Writes content to a file, creating it if it doesn't exist or overwriting if it does.
writefile(path: string, contents: string) -> void| Parameter | Type | Description |
|---|---|---|
path | string | Relative path to the file |
contents | string | Content to write |
Example
writefile("settings.json", '{"theme": "dark"}')appendfile
Appends content to the end of an existing file.
appendfile(path: string, contents: string) -> void| Parameter | Type | Description |
|---|---|---|
path | string | Relative path to the file |
contents | string | Content to append |
Example
appendfile("log.txt", "New log entry\n")listfiles
Returns an array of file and folder names in the specified directory.
listfiles(path: string) -> {string}| Parameter | Type | Description |
|---|---|---|
path | string | Relative path to the directory |
Example
local files = listfiles("scripts")
for _, file in pairs(files) do
print(file)
endisfolder
Returns true if the given path is an existing folder.
Aliases: folderexist
isfolder(path: string) -> booleanExample
if isfolder("scripts") then
print("Scripts folder exists!")
endisfile
Returns true if the given path is an existing file.
Aliases: filexist
isfile(path: string) -> booleanExample
if isfile("config.lua") then
loadstring(readfile("config.lua"))()
endmakefolder
Creates a directory. Creates parent directories recursively if needed.
Aliases: createfolder
makefolder(path: string) -> voidExample
makefolder("data/saves/player")delfile
Deletes a file.
Aliases: deletefile
delfile(path: string) -> voidExample
if isfile("old_config.txt") then
delfile("old_config.txt")
enddelfolder
Deletes a folder and its contents.
Aliases: deletefolder
delfolder(path: string) -> voidExample
if isfolder("temp") then
delfolder("temp")
endgetcustomasset
Returns a Content string (rbxasset://) that can be used in Roblox properties to reference a file from the workspace folder.
Aliases: loadcustomasset, getsynasset, syncustomasset, getasset
getcustomasset(path: string) -> string| Parameter | Type | Description |
|---|---|---|
path | string | Relative path to the asset file |
Example
local imageLabel = Instance.new("ImageLabel")
imageLabel.Image = getcustomasset("images/logo.png")
imageLabel.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui