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.
writefile(path, content)Creates or replaces a file. Missing folders are created. Raises on a refused extension or when path is a folder.
| Name | Type | Description |
|---|---|---|
path | string | |
content | string |
writefile("settings.json", "{}")readfile(path) -> stringThe contents of a file. Raises when it does not exist: check with isfile first.
| Name | Type | Description |
|---|---|---|
path | string |
string
if isfile("settings.json") then
local text = readfile("settings.json")
endappendfile(path, content)Adds content to the end of a file, creating it if needed.
| Name | Type | Description |
|---|---|---|
path | string | |
content | string |
appendfile("log.txt", "started\n")makefolder(path)Creates a folder and any missing parent. Nothing happens when it exists. Raises when a file is in the way.
| Name | Type | Description |
|---|---|---|
path | string |
makefolder("configs")isfile(path) -> booleantrue when path is a file. Never raises.
| Name | Type | Description |
|---|---|---|
path | string |
boolean
isfolder(path) -> booleantrue when path is a folder. Never raises.
| Name | Type | Description |
|---|---|---|
path | string |
boolean
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.
| Name | Type | Description |
|---|---|---|
path | string |
{ string }
for _, p in ipairs(listfiles("configs")) do print(p) enddelfile(path) -> booleanDeletes a file or an empty folder: true when something was removed, false when nothing was there. Raises on a folder that is not empty.
| Name | Type | Description |
|---|---|---|
path | string |
boolean
delfile("log.txt")delfolder(path) -> booleanDeletes a folder with everything in it (or a file). Returns true.
| Name | Type | Description |
|---|---|---|
path | string |
boolean
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.
httpget(url [, headers]) -> stringSends a GET request and returns the response body.
| Name | Type | Description |
|---|---|---|
url | string | |
headersoptional | { [string]: string } |
string
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)
endhttppost(url, body [, contentType] [, headers]) -> stringPosts body to url and gives back what the server answered. A Content-Type in headers wins over contentType, and "" sends none.
| Name | Type | Default | Description |
|---|---|---|---|
url | string | ||
body | string | ||
contentTypeoptional | string | "application/json" | |
headersoptional | { [string]: string } |
string
httppost("https://example.com/api", '{"ping":true}')