Skip to content

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.

lua
readfile(path: string) -> string
ParameterTypeDescription
pathstringRelative path to the file

Example

lua
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.

lua
writefile(path: string, contents: string) -> void
ParameterTypeDescription
pathstringRelative path to the file
contentsstringContent to write

Example

lua
writefile("settings.json", '{"theme": "dark"}')

appendfile

Appends content to the end of an existing file.

lua
appendfile(path: string, contents: string) -> void
ParameterTypeDescription
pathstringRelative path to the file
contentsstringContent to append

Example

lua
appendfile("log.txt", "New log entry\n")

listfiles

Returns an array of file and folder names in the specified directory.

lua
listfiles(path: string) -> {string}
ParameterTypeDescription
pathstringRelative path to the directory

Example

lua
local files = listfiles("scripts")
for _, file in pairs(files) do
    print(file)
end

isfolder

Returns true if the given path is an existing folder.

Aliases: folderexist

lua
isfolder(path: string) -> boolean

Example

lua
if isfolder("scripts") then
    print("Scripts folder exists!")
end

isfile

Returns true if the given path is an existing file.

Aliases: filexist

lua
isfile(path: string) -> boolean

Example

lua
if isfile("config.lua") then
    loadstring(readfile("config.lua"))()
end

makefolder

Creates a directory. Creates parent directories recursively if needed.

Aliases: createfolder

lua
makefolder(path: string) -> void

Example

lua
makefolder("data/saves/player")

delfile

Deletes a file.

Aliases: deletefile

lua
delfile(path: string) -> void

Example

lua
if isfile("old_config.txt") then
    delfile("old_config.txt")
end

delfolder

Deletes a folder and its contents.

Aliases: deletefolder

lua
delfolder(path: string) -> void

Example

lua
if isfolder("temp") then
    delfolder("temp")
end

getcustomasset

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

lua
getcustomasset(path: string) -> string
ParameterTypeDescription
pathstringRelative path to the asset file

Example

lua
local imageLabel = Instance.new("ImageLabel")
imageLabel.Image = getcustomasset("images/logo.png")
imageLabel.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui