Globals and libraries
The functions every script has, the console, waiting and threads, and the Lua base library.
loadstring(chunk [, chunkname]) -> function, string?Compiles chunk into a function. Calling it runs the code and returns what its top level returns. On a syntax error you still get a function, which prints the error when called. The message comes back as the second value.
Standard Luau returns nil and the message on a syntax error. Here the first value is a function either way, so test the second one.
| Name | Type | Default | Description |
|---|---|---|---|
chunk | string | Luau source. | |
chunknameoptional | string | "loadstring" | The name errors show. |
functionstring?
local f, err = loadstring("return 1 + 1")
if err then warn(err) else print(f()) endload(chunk [, chunkname]) -> function, string?The same function as loadstring.
See loadstring: a syntax error returns a function that prints it.
| Name | Type | Description |
|---|---|---|
chunk | string | |
chunknameoptional | string |
functionstring?
local f = load("print('hi')")WorldToScreen(position) -> Vector2, booleanProjects a world position onto the Roblox window. Returns the point in client pixels (top left is 0, 0: the space of Drawing, mousemoveabs and Camera.ViewportSize) and whether it is visible. A point outside the window, or one the camera faces away from, comes back as (0, 0) and false.
| Name | Type | Description |
|---|---|---|
position | Vector3 |
Vector2pointClient pixels.booleanonScreen
local pos, visible = WorldToScreen(part.Position)
if visible then
print(pos.X, pos.Y)
endnotify(message [, title] [, duration])Shows a notification at the right edge of the Roblox window for duration seconds (0.1 to 120). At most six show at once, and a seventh pushes out the oldest.
| Name | Type | Default | Description |
|---|---|---|---|
message | string | ||
titleoptional | string | "" | |
durationoptional | number | 5 |
notify("Loaded", "My script", 3)identifyexecutor() -> string, stringThe runtime's name and version: "evasive" and "1.0.0".
stringstring
local name, version = identifyexecutor()getgamename() -> stringThe name of the experience you are in, as the Roblox website lists it. Fetched once per game, then cached. Returns "" when no game is loaded. Yields while it fetches.
string
print(getgamename())getscripts() -> { Instance }Every LocalScript, ModuleScript and Script in the game. It can be a long list, and the call yields while it walks the tree.
{ Instance }
print(#getscripts())base64encode(data) -> stringEncodes data as standard Base64. Every byte is encoded, NUL bytes included.
| Name | Type | Description |
|---|---|---|
data | string |
string
local b = base64encode("hello")base64decode(data) -> stringDecodes Base64 back to the original bytes. Raises on text that is not Base64. An empty string gives "".
| Name | Type | Description |
|---|---|---|
data | string |
string
print(base64decode("aGVsbG8="))getping() -> numberYour ping to the game server in milliseconds, from Roblox's own network stats. 0 while no place is loaded.
number
print(getping())tick() -> numberSeconds from a steady clock, for timing. Subtract two readings to get the time between them. It does not tell the date. Use os.time for that.
Roblox's tick() is Unix time. This one counts from an arbitrary start, so only differences mean anything.
number
local t0 = tick()
-- work
print(tick() - t0)typeof(value) -> stringLike type, but names Roblox types: Vector3, CFrame, Color3, Instance, Drawing, EnumItem, RBXScriptSignal and so on, where type says userdata.
| Name | Type | Description |
|---|---|---|
value | any |
string
print(typeof(Vector3.new()))getfenv([target]) -> tableThe environment of a function, or of a call level. With no argument, 0 or 1 you get the script's own environment, every global included. _G is a separate table that every running script shares.
| Name | Type | Description |
|---|---|---|
targetoptional | (function | number) |
table
getfenv().myValue = 1setfenv(target, env) -> functionSets the environment of a function (or of a call level): its global names are then looked up in env. Returns the function.
| Name | Type | Description |
|---|---|---|
target | function | number | |
env | table |
function
setfenv(f, { print = print })getrbxversion() -> stringThe running Roblox client's version, as its log files name it (e.g. "0.749.0.7491426").
string
print(getrbxversion())gethwid() -> stringAn identifier of this PC. It is the same on every call.
string
local id = gethwid()queue_on_teleport(source)Queues source to run after your next teleport to another server or place. It is compiled now, so a syntax error raises here. It runs as a thread of the script that queued it, with that script's globals. That script keeps running until then.
| Name | Type | Description |
|---|---|---|
source | string |
queue_on_teleport([[print("arrived")]])queueonteleport(source)The same function as queue_on_teleport.
| Name | Type | Description |
|---|---|---|
source | string |
queueonteleport([[print("arrived")]])getaimtarget() -> Instance?The character evasive's aim is locked on to right now, or nil when it has none or the aim is off. A player comes back as its Character model.
Instance?
local t = getaimtarget()
if t then print(t:GetFullName()) endgettriggertarget() -> Instance?The character under evasive's trigger at this moment, or nil.
Instance?
local t = gettriggertarget()cancallserver() -> booleanAlways false: evasive works from outside the game. The functions that need code inside the client are not available.
boolean
if not cancallserver() then print("external") enddecompile(script) -> stringWould return a script's source. Prints why it cannot and returns "".
A script's bytecode cannot be read: evasive reads Roblox memory from outside, and the bytecode it would need is compressed and protected. The call prints this and returns an empty string.
| Name | Type | Description |
|---|---|---|
script | Instance |
string
getscripthash(script) -> stringWould hash a script's bytecode.
A script's bytecode cannot be read: evasive reads Roblox memory from outside, and the bytecode it would need is compressed and protected. The call raises.
| Name | Type | Description |
|---|---|---|
script | Instance |
string
getscriptbytecode(script) -> stringWould return a script's compiled bytecode.
A script's bytecode cannot be read: evasive reads Roblox memory from outside, and the bytecode it would need is compressed and protected. The call raises.
| Name | Type | Description |
|---|---|---|
script | Instance |
string
firetouchinterest(part, target, state)Would fire a touch (state 0) or untouch (1) between two parts.
Needs code running inside the Roblox client. evasive reads and writes the game's memory from outside, so this call checks its arguments and then raises. cancallserver() is always false.
| Name | Type | Description |
|---|---|---|
part | BasePart | |
target | BasePart | |
state | number |
fireclickdetector(detector [, distance] [, event])Would fire a ClickDetector (MouseClick, RightMouseClick, MouseHoverEnter or MouseHoverLeave).
Needs code running inside the Roblox client. evasive reads and writes the game's memory from outside, so this call checks its arguments and then raises. cancallserver() is always false.
| Name | Type | Description |
|---|---|---|
detector | Instance | |
distanceoptional | number | |
eventoptional | string |
fireproximityprompt(prompt)Would trigger a ProximityPrompt at once.
Needs code running inside the Roblox client. evasive reads and writes the game's memory from outside, so this call checks its arguments and then raises. cancallserver() is always false.
| Name | Type | Description |
|---|---|---|
prompt | Instance |
print(...)Writes its arguments to the console, separated by spaces.
| Name | Type | Description |
|---|---|---|
... | any |
print("health", 100)warn(...)Writes a yellow warning line.
| Name | Type | Description |
|---|---|---|
... | any |
warn("low health")error(...)Writes a red error line and returns. The script keeps running. To raise an error that pcall catches, use assert(false, message).
Standard Luau's error raises. Here it only prints.
| Name | Type | Description |
|---|---|---|
... | any |
error("not in a game")Scheduler & modules
Yielding, threads and modules. Scripts run on their own thread, which steps 240 times a second. A script that runs 3 seconds without yielding is stopped.
wait([seconds]) -> numberYields the current thread for seconds (by default until the next tick) and returns the time that passed.
| Name | Type | Description |
|---|---|---|
secondsoptional | number |
number
while wait(0.5) do
print("tick")
endspawn(fn, ...) -> threadRuns fn on a new thread at once, with the extra arguments. The caller continues when it yields or ends.
| Name | Type | Description |
|---|---|---|
fn | function | |
... | any |
thread
spawn(function() wait(1) print("later") end)require(path) -> anyRuns a module and returns what it returns, once per script (later calls get the same value). path is a .lua or .luau file relative to the scripts folder, not the readfile workspace, and it cannot leave that folder. A path without an extension, another extension or a missing file raises an error that names the path.
| Name | Type | Description |
|---|---|---|
path | string |
any
local util = require("lib/util.luau")setfastflag(flag, value)Checks that both arguments are strings and does nothing else.
evasive leaves the client's fast flags alone. The function is there so scripts that call it keep loading.
| Name | Type | Description |
|---|---|---|
flag | string | |
value | string |
getfastflag(flag) -> numberReturns 0 for every flag.
evasive does not read the client's fast flags. The stub returns 0 so scripts that call it keep loading.
| Name | Type | Description |
|---|---|---|
flag | string |
number
task.spawn(fn, ...) -> threadRuns fn on a new thread now, passing the extra arguments, and returns the thread. The caller continues when fn yields or ends.
| Name | Type | Description |
|---|---|---|
fn | function | |
... | any |
thread
task.spawn(print, "hi")task.defer(fn, ...) -> threadRuns fn on a new thread later in the same scheduler cycle, after the work already queued.
| Name | Type | Description |
|---|---|---|
fn | function | |
... | any |
thread
task.defer(function() print("after") end)task.delay(seconds, fn, ...) -> threadRuns fn on a new thread after seconds.
| Name | Type | Description |
|---|---|---|
seconds | number | |
fn | function | |
... | any |
thread
task.delay(2, print, "two seconds later")task.wait([seconds]) -> numberYields for seconds (by default until the next tick) and returns the time that passed.
| Name | Type | Description |
|---|---|---|
secondsoptional | number |
number
local dt = task.wait()task.cancel(thread)Cancels a thread: one that is waiting or not started yet never runs again.
| Name | Type | Description |
|---|---|---|
thread | thread |
local t = task.delay(5, print, "never")
task.cancel(t)Lua base library
Luau 0.748's standard globals. The string, table, math, bit32, buffer, coroutine and utf8 libraries work as Luau documents them. os has clock, time, date and difftime, and debug has info and traceback. This list covers the base functions.
type(value) -> stringThe Luau type. Roblox datatypes and instances are "userdata". Use typeof for their names.
| Name | Type | Description |
|---|---|---|
value | any |
string
print(type(Vector3.new()))tostring(value) -> stringConverts a value to text, honouring __tostring.
Roblox datatypes print with their type name and four decimals: tostring(Vector3.new(1, 2, 3)) is "Vector3(1.0000, 2.0000, 3.0000)", where Roblox prints "1, 2, 3".
| Name | Type | Description |
|---|---|---|
value | any |
string
print(tostring(Vector3.new(1, 2, 3)))tonumber(value [, base]) -> number?Parses a number (spaces trimmed, 0x hex accepted, base 2 to 36), or nil.
| Name | Type | Description |
|---|---|---|
value | any | |
baseoptional | number |
number?
print(tonumber("ff", 16))pairs(t) -> function, table, anyIterates every key of a table (the raw table: __iter is not used).
| Name | Type | Description |
|---|---|---|
t | table |
functiontableany
for k, v in pairs(t) do endipairs(t) -> function, table, numberIterates t[1], t[2], ... up to the first nil.
| Name | Type | Description |
|---|---|---|
t | table |
functiontablenumber
for i, v in ipairs(list) do endnext(t [, key]) -> any, anyThe key after key in a table, and its value.
| Name | Type | Description |
|---|---|---|
t | table | |
keyoptional | any |
anyany
select(n, ...) -> ...anyThe arguments from the nth on. A negative n counts from the end, and "#" gives the count.
| Name | Type | Description |
|---|---|---|
n | number | string | |
... | any |
...any
print(select("#", 1, 2, 3))unpack(t [, i] [, j]) -> ...anyt[i] to t[j] (by default 1 to #t). The same as table.unpack.
| Name | Type | Description |
|---|---|---|
t | table | |
ioptional | number | |
joptional | number |
...any
print(unpack({ 1, 2, 3 }))assert(value, ... [, message]) -> ...anyRaises an error pcall can catch when value is false or nil, with message or "assertion failed!". Otherwise it returns all its arguments. Use it to raise errors, since error() only prints.
| Name | Type | Description |
|---|---|---|
value | any | |
messageoptional | string | |
... | any |
...any
assert(player, "no player")pcall(f, ...) -> boolean, ...anyCalls f in protected mode: true and its results, or false and the error message with the script name and line.
| Name | Type | Description |
|---|---|---|
f | function | |
... | any |
boolean...any
local ok, err = pcall(function() return nil + 1 end)xpcall(f, handler, ...) -> boolean, ...anyLike pcall, with handler called on the error message. The extra arguments go to f.
| Name | Type | Description |
|---|---|---|
f | function | |
handler | function | |
... | any |
boolean...any
xpcall(f, warn, 1, 2)setmetatable(t [, mt]) -> tableSets t's metatable and returns t. A metatable with __metatable is protected and cannot be changed.
| Name | Type | Description |
|---|---|---|
t | table | |
mtoptional | table |
table
getmetatable(value) -> anyThe metatable, or its __metatable field when it has one.
| Name | Type | Description |
|---|---|---|
value | any |
any
newproxy([withMetatable]) -> userdataA blank userdata. With true it gets its own metatable (getmetatable returns it) so metamethods work.
| Name | Type | Description |
|---|---|---|
withMetatableoptional | boolean |
userdata
local p = newproxy(true)rawget(t, key) -> anyReads t[key] without metamethods.
| Name | Type | Description |
|---|---|---|
t | table | |
key | any |
any
rawset(t, key, value) -> tableWrites t[key] without metamethods and returns t.
| Name | Type | Description |
|---|---|---|
t | table | |
key | any | |
value | any |
table
rawequal(a, b) -> booleanCompares without __eq.
| Name | Type | Description |
|---|---|---|
a | any | |
b | any |
boolean
rawlen(value) -> numberThe length without __len.
| Name | Type | Description |
|---|---|---|
value | table | string |
number
gcinfo() -> numberThe Luau VM's memory use in kilobytes. Every script runs in the same VM.
number
print(gcinfo())