Docs / File system

File system

Read, write, list, and delete files under the executor's Workspace folder.

Library#02 of 23 Functions12
readfile(path: string) → string
Read the whole file. Binary-safe.
lua
local text = readfile("notes.txt")
print(text)
writefile(path: string, contents: string)
Overwrite (or create) the file. Binary-safe.
lua
writefile("save.json", game:GetService("HttpService"):JSONEncode({hp=100}))
appendfile(path: string, contents: string)
Append bytes to a file, creating it if absent.
lua
appendfile("log.txt", os.date() .. " — event\n")
isfile(path: string) → boolean
Whether the path is a readable file.
lua
if isfile("save.json") then print("save exists") end
isfolder(path: string) → boolean
Whether the path is a directory.
lua
if not isfolder("dumps") then makefolder("dumps") end
delfile(path: string)
Delete a file.
lua
delfile("tmp.txt")
delfolder(path: string)
Delete a directory and its contents.
lua
delfolder("dumps/old")
makefolder(path: string)
Create a directory (nested — parent dirs are created as needed).
lua
makefolder("dumps/2026-07/players")
listfiles(path: string) → {string}
List all entries (files and folders) directly inside path.
lua
for _, name in ipairs(listfiles("dumps")) do
    print(name)
end
loadfile(path: string, chunkname: string?) → function | nil, string?
Compile a file's contents into a closure.
lua
local f, err = loadfile("scripts/main.lua")
if f then f() else warn(err) end
getcustomasset(path: string) → string
Returns a rbxasset://-style URL your game can use as an image/sound/etc. asset.
lua
local img = Instance.new("ImageLabel", gui)
img.Image = getcustomasset("images/logo.png")
setclipboard(text: string)
Set the OS clipboard contents.
aliasessetrbxclipboard, toclipboard
lua
setclipboard(game.Players.LocalPlayer.UserId)