evasivedocs
Roblox scriptingLuau 0.748 · 24 guides · 385 API entries
API reference

Files and HTTP

The workspace folder and web requests.

File system

Files in the workspace folder, Documents\evasive roblox\workspace. Paths are relative to it, / and \ both work, and nothing outside it can be reached. readfile, writefile and appendfile take .txt, .lua, .luau, .json, .cfg, .dat and .ini files only ("file extension not allowed" otherwise). Contents are binary-safe.

9 entries

writefile

function
writefile(path, content)

Creates or replaces a file. Missing folders are created. Raises on a refused extension or when path is a folder.

Arguments
NameTypeDescription
pathstring
contentstring
Example
Luau
writefile("settings.json", "{}")

readfile

function
readfile(path) -> string

The contents of a file. Raises when it does not exist: check with isfile first.

Arguments
NameTypeDescription
pathstring
Returns
  • string
Example
Luau
if isfile("settings.json") then
    local text = readfile("settings.json")
end

appendfile

function
appendfile(path, content)

Adds content to the end of a file, creating it if needed.

Arguments
NameTypeDescription
pathstring
contentstring
Example
Luau
appendfile("log.txt", "started\n")

makefolder

function
makefolder(path)

Creates a folder and any missing parent. Nothing happens when it exists. Raises when a file is in the way.

Arguments
NameTypeDescription
pathstring
Example
Luau
makefolder("configs")

isfile

function
isfile(path) -> boolean

true when path is a file. Never raises.

Arguments
NameTypeDescription
pathstring
Returns
  • boolean

isfolder

function
isfolder(path) -> boolean

true when path is a folder. Never raises.

Arguments
NameTypeDescription
pathstring
Returns
  • boolean

listfiles

function
listfiles(path) -> { string }

The files and folders directly inside path, as workspace-relative paths in alphabetical order. An empty path lists the workspace itself. Raises when path is missing or is a file.

Arguments
NameTypeDescription
pathstring
Returns
  • { string }
Example
Luau
for _, p in ipairs(listfiles("configs")) do print(p) end

delfile

function
delfile(path) -> boolean

Deletes a file or an empty folder: true when something was removed, false when nothing was there. Raises on a folder that is not empty.

Arguments
NameTypeDescription
pathstring
Returns
  • boolean
Example
Luau
delfile("log.txt")

delfolder

function
delfolder(path) -> boolean

Deletes a folder with everything in it (or a file). Returns true.

Arguments
NameTypeDescription
pathstring
Returns
  • boolean
Example
Luau
delfolder("old")

HTTP

HTTP and HTTPS requests. Both yield until the answer arrives (at most 30 seconds) and never raise: an error status returns the server's body, a failed connection returns "". game:HttpGet and game:HttpPost do the same.

2 entries

httpget

function
httpget(url [, headers]) -> string

Sends a GET request and returns the response body.

Arguments
NameTypeDescription
urlstring
headersoptional{ [string]: string }
Returns
  • string
Example
Luau
local text = httpget("https://example.com/status.json")
if text == "" then
    warn("no answer")
else
    local status = game:GetService("HttpService"):JSONDecode(text)
    print(status.online)
end

httppost

function
httppost(url, body [, contentType] [, headers]) -> string

Posts body to url and gives back what the server answered. A Content-Type in headers wins over contentType, and "" sends none.

Arguments
NameTypeDefaultDescription
urlstring
bodystring
contentTypeoptionalstring"application/json"
headersoptional{ [string]: string }
Returns
  • string
Example
Luau
httppost("https://example.com/api", '{"ping":true}')