Elysian Lua API Documentation v3.3.9a 12/12/2020


getrawmetatable

table getrawmetatable(variant<table, userdata> obj)

Returns the metatable from a table or userdata, even if it is locked.

setrawmetatable

boolean setrawmetatable(variant<table, userdata> obj, table val)

Sets the metatable of a table or userdata, even if it is locked.

isreadonly

boolean isreadonly(table val)

Returns true if the table is read-only.

setreadonly

boolean setreadonly(table tab, boolean readonly)

Sets the read-only flag of a table.

printconsole

boolean printconsole(string val [, number r, number g, number b])

Prints val to Elysian’s console with color r, g, b. Default color is 0, 0, 200.

printdebug

boolean printdebug(string val)

Prints val to the console (View->Console->Toggle)

getobjects

string content)

Internal function used by DataModel::GetObjects (see init.lua)

readfile

string readfile(string filename)

Returns the contents of a file in the workspace folder

loadfile

function loadfile(string filename)

Loads a file from the workspace folder. Returns nil and an error on error. Similar to executing loadstring(readfile(filename)).

getgenv

table getgenv()

Returns the global environment for Elysian.

getrenv

table getrenv()

Returns the global environment for game scripts.

Clipboard.set

boolean Clipboard.set(string data)

Sets the contents of the clipboard to data.

mouse1press

void mouse1press([number x, number y])

Presses the left mouse button.

mouse1release

void mouse1release([number x, number y])

Releases the left mouse button.

mouse1click

void mouse1click([number delay, number x, number y])

Clicks the left mouse button with an optional delay in between press and release. Delay default is ~0.03 seconds.

mouse2press

void mouse2press([number x, number y])

Presses the right mouse button.

mouse2release

void mouse2release([number x, number y])

Releases the right mouse button.

mouse2click

void mouse2click([number delay, number x, number y])

Clicks the right mouse button with an optional delay in between press and release. Delay default is ~0.03 seconds.

keypress

void keypress(KeyCode key)

Presses a key. If a number is passed for key, Elysian will interpret it as a virtual key code and attempt to convert it to a KeyCode for compatibility with scripts created for older versions of Elysian.

keyrelease

void keyrelease(KeyCode key)

Releases a key. If a number is passed for key, Elysian will interpret it as a virtual key code. See keypress.

mousemove

void mousemove(number x, number y [, number dx, number dy])

Moves the cursor to a location inside Roblox’s window. dx and dy are optional mouse delta parameters to be sent to Roblox. If not provided, they are equivalent to x - current_mouse_position.X and y - current_mouse_position.Y respectively.

mousemoverel

void mousemoverel(number dx, number dy)

Moves the cursor relatively.

mousescroll

void mousescroll(boolean forward [, number x, number y])

Scrolls the mouse. For compatibility with scripts created for older versions of Elysian, a number can be passed to forward where a positive number scrolls the mouse up, a negative number scrolls the mouse down, and one scroll “click” is equal to 120.

writefile

boolean writefile(string filename, string data [, boolean binary])

Writes data to a file in the workspace folder. Returns true if successful.

appendfile

boolean appendfile(string filename, string data [, boolean binary])

Appends data to a file in the workspace folder. Returns true if successful.

mkdir

boolean mkdir(string path)

Creates a directory in the workspace folder. Returns true if successful.

saveinstance

void saveinstance(variant<Instance, table> instance, string name [, table options])

Saves an instance to a file in the workspace folder which can be later opened in Roblox Studio. Possible options (and their default values) can be seen below:

DefaultSettings = {
    DecompileMode = 0, -- 0 = don't decompile scripts, 1 = Synapse X Decompiler
    NilInstances = false, -- save nil instances
    RemovePlayerCharacters = true, -- ignore players' characters
    SavePlayers = false, -- saves players and their descendants
    DecompileTimeout = 10, -- process timeout
    MaxThreads = 3, -- the max number of processes that should be running at one time (the higher this value is the faster the decompilation process)
    DecompileIgnore = {"Chat","CoreGui","CorePackages"}, -- scripts inside these services are saved but not decompiled
    ShowStatus = true, -- whether to show status text
    IgnoreDefaultProps = true,
    IsolateStarterPlayer = true -- allows for playing the game in studio right after opening
}

instance can be a table of instances to save multiple instances at once.

saveplace

void saveplace(string name [, table options])

Equivalent to saveinstance(game, name, options)

decompile

boolean decompile(variant<Instance, function> script, function callback(string result, string error), number timeout = 5)

Attempts to decompile script. If invalid parameters are passed, nil and an error is returned. If not, decompile returns with true and a (Windows) thread is created that spawns an external process and waits for its output. Once the process ends, the callback is called with the result. If the process is unable to start or another error occurs, the callback is called with nil and the error. WARNING: A new process is created every time this function is called. Calling decompile too quickly or in excessive amounts may cause some processes to hang or exhaust your computer of resources.

checkcaller

boolean checkcaller()

Returns true if the function calling the function calling checkcaller is an Elysian function.

setfflag

boolean setfflag(string fflag, string value)

Sets an FFlag’s value. Returns true if the flag was set succesfully or false if the flag doesn’t exist. For more information on FFlags and how to retrieve their values, see: http://wiki.roblox.com/index.php?title=API:Class/GlobalSettings/GetFFlag

getreg

table getreg()

Returns Lua’s registry (LUA_REGISTRYINDEX).

getnilinstances

table getnilinstances()

Returns a list of nil instances.

elysianexecute

void elysianexecute(string script [, Instance localscript])

Equivalent to executing a script through Elysian’s interface (pressing the execute button, etc). If localscript is provided, the script will be binded/linked to that instance. If not present, a new LocalScript will be created.

newcclosure

function newcclosure(function f)

Disguises Lua function f as a C function. It is seen as a C function by other scripts and any errors thrown inside f are viewed as coming from the C function, not f (in other words, the existence of f can not be detected by viewing the error message, stack trace, or etc.). f is allowed to yield ( e.g. wait() ) but will resume outside of the function.

replaceclosure

function replaceclosure(function target, function replacement)

Replaces a function with another function and returns a clone of the original. Once a function is replaced it cannot be replaced with any other function except for its clone/original. For a better understanding, see this code. Warning: It should be noted that Lua doesn’t like people modifying internal structures and improper or extensive use of this function may cause unexpected crashes or other issues.

restoreclosure

boolean restoreclosure(function target)

Restores a closure that has been overwritten with replaceclosure. Returns false if the function has not been replaced.

bit library

functions: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror

Attempts to replicate LuaJIT’s bit library.

getallthreads

table getallthreads()

Returns an array of all existing Lua threads.

getthreadobject

Instance getthreadobject([thread t])

Returns the script associated with a Lua thread. If t is not provided, the current thread is used.

gettenv

table gettenv([thread t])

Returns a thread’s environment. If t is not provided, the current thread is used.

getsenv

table getsenv(Instance script)

Searches for a thread associated with script and returns its environment (see init.lua for implementation).

getlocals

table getlocals(number level)

Returns a Lua function’s local variables. The level parameter represents a function on the callstack, where 1 is the function calling getlocals, 2 is the function calling that function, and so on. The level provided cannot point to an Elysian or C function.

In Luau-enabled games, getlocals returns the function’s stack as an array instead of a dictionary of local names to local variables.

setlocal

boolean setlocal(number level, string i, variant v)

Sets local variable i to value v in the function pointed to by level (see getlocals). Like getlocals, the function cannot be an Elysian or C function. Returns true if the variable was set successfully.

In Luau-enabled games, setlocal requires an integer index for i instead of a string.

getupvals

table getupvals(variant<number, function> f)

Returns a Lua function’s upvalues. If a number is passed for f, it is interpreted as a level (see getlocals and setlocal). The function cannot be an Elysian or C function.

In Luau-enabled games, getupvals returns the function’s upvalues as an array instead of a dictionary of upvalue names to upvalues.

setupval

boolean setupval(variant<number, function> f, string i, variant v)

Sets upvalue i to value v in function f. If a number is passed for f, it is interpreted as a level (see getlocals and setlocal). The function cannot be an Elysian or C function. Returns true if the upvalue was set successfully.

In Luau-enabled games, setupval requires an integer index for i instead of a string.

getconsts

table getconsts(variant<number, function> f)

Returns a Lua function’s constants. If a number is passed for f, it is interpreted as a level.

setconst

void setconst(variant<number, function> f, number i, variant v)

Sets constant number i to value v in function f. If a number is passed for f, it is interpreted as a level.

getgc

table getgc([boolean nomt])

Returns an array of all existing allocated objects in Lua. This includes strings, functions, threads, userdata, and more across all Roblox and Elysian scripts. Unless nomt is set, the returned table has a metatable with __mode set to “v”.

islclosure

boolean islclosure(function f)

Returns true if f is a Lua function.

gethui

Instance gethui()

Returns a hidden renderable container separate from CoreGui, PlayerGui, and et cetera. ScreenGuis and Messages parented to this container will render on top of CoreGui. Although parented to Game, game scripts cannot enumerate Game’s children to find this container or use functions such as FindFirstChild to find the container or any of its descendants. Objects added to and removed from the container will not fire DescendantAdded or DescendantRemoving signals on Game.

getbspval

string getbspval(Instance object, string property [, boolean base64])

Reads a BinaryString property’s value. Useful for reading conventionally unreadable BinaryString properties such as Terrain.SmoothGrid, PartOperation.PhysicsData, BinaryStringValue.Value, and so on.

getnspval

variant getnspval(Instance object, string property)

Returns a property’s value, even if it is unscriptable.

getpcd

string getpcd(Instance union)

Returns a 16-byte hash and binary data corresponding to TriangleMeshPart’s PhysicalConfigData property.

cloneref

Instance cloneref(Instance ref)

Clones a reference to an instance. clone==ref will be false, but both values will point to the same instance.

md5sum

string md5sum(string data)

Returns the MD5 sum of data.

base64encode

string base64encode(string data)

Returns data base64-encoded.

base64decode

string base64decode(string data)

Returns data base64-decoded.

getunionassetid

string getunionassetid(Instance union)

Equivalent to getnspval(union, "AssetId")

getconnections

table getconnections(RBXScriptSignal signal)

Returns a list of Lua and engine connections to signal.

isluau

boolean isluau()

Returns true if the game is running on Roblox’s new Lua implementation, Luau.

getnamecallmethod

string getnamecallmethod()

Returns the method parameter in the context of a __namecall metamethod. Only applies to Luau-enabled games. See init.lua for example usage.

getelyasset

string getelyasset([string name])

Returns a string in the format rbxasset://<random_string>/<name> that can be used with Content properties to load custom assets from the workspace folder.

Drawing Library

Drawing.new

Drawable Drawing.new(string type)

Creates a new drawable object. type must be “Circle”, “Box”, “Line”, or “Text”. See below for more information.

Drawing::GetObjects

table Drawing:GetObjects()

Returns a list of all drawable objects.

Drawing.DefaultFont

int Drawing.DefaultFont

A value between 1 and 21, inclusive. Default 21.

Drawing.UseCompatTransparency

boolean Drawing.UseCompatTransparency

If true, 0 will indicate transparency and 1 will indicate opaqueness when setting a drawable’s Transparency property.

Drawable (Base Class)

Properties

string ClassName [readonly]

The type of drawable.

Vector2 Position

The position of the drawable. A position of (0, 0) marks the top left corner of the screen.

Color3 Color

The color of the drawable.

boolean Visible

The drawable’s visibility.

int ZIndex

The drawable’s layer. This number can be 0 to 25. Drawables on higher layers will render over drawables on lower layers.

float Transparency

A value from 0 to 1. A value of 1 means the drawable is completely transparent.

Functions

void Drawable:Destroy()

Destroys a drawable. Further access to the object will throw an error.

void Drawable:Remove()

Equivalent to drawable:Destroy()

Drawable Drawable:Clone()

Constructs a new drawable with equal properties.

Circle

Properties

float Radius

The circle’s radius.

int Segments

The number of segments that make up the circle. Default 20.

boolean Filled

Whether or not the circle is filled. Default false.

float Thickness

The circle’s thickness. Applies only when Filled is false.

Box

Properties

Vector2 Size

The box’s size.

float Rounding

The roundness of the box’s corners. Default 0.

boolean Filled

Whether or not the box is filled. Default false.

float Thickness

The box’s thickness. Applies only when Filled is false.

Line

Properties

Vector2 EndPosition

The line’s end position.

float Thickness

The line’s thickness.

Text

Properties

float FontSize

Font size.

string Text

The string to display.

float WrapWidth

If greater than 0, the maximum width, in pixels, before text is wrapped. Default 0.

int Font

A value between 0 and 21, inclusive. A value of 0 indicates a default font controlled by the Drawing.DefaultFont property. Fonts for values 1 to 20 can be found here.

Vector2 TextBounds [readonly]

The width and height of the text.

boolean Outline

Indicates whether the text is outlined.

Color3 OutlineColor

The outline’s color.

Luau

Luau is a custom, speedy Lua implementation created by Roblox. It was first spotted in early April of 2019 before being publicly announced by Roblox in late June. Luau does not change Lua’s syntax or behavior but implements a much faster runtime using optimizations in the parser and virtual machine.

Elysian Support (v3.3.0+) & Developer Notes

RBXScriptSignal Extensions

Properties

boolean Scriptable [readonly]

Determines whether or not a signal is scriptable. Calling Connect or Wait on non-scriptable signals has no effect.

Functions

RBXScriptConnection RBXScriptSignal:Connect(function func)

In Elysian, Connect works as normal but can also register connections to non-scriptable signals. A list of non-scriptable/internal signals will appear here in the future.

table RBXScriptSignal:GetConnections()

Equivalent to getconnections(signal)

RBXScriptConnection Extensions

Properties

boolean LuaConnection [readonly]

Determines whether or not the connection is attached to a Lua function.

boolean Enabled

Determines whether or not the connection is enabled. Disabled connections will not fire. Both Lua and engine connections can be disabled. Anti-AFK can now by achieved with a few lines of code:

for i, v in pairs(game:GetService"Players".LocalPlayer.Idled:GetConnections()) do
    if not v.LuaConnection then
        v.Enabled = false
    end
end

This works by disabling a connection created by Roblox’s engine responsible for kicking the client when the user has been idle for more than 20 minutes.

Functions

function RBXScriptConnection:GetFunction()

Returns a connection’s associated Lua function or nil if the connection is not a Lua connection or the function belongs to another Lua instance (corescript state, etc.)

void RBXScriptConnection:GetThread()

Returns a connection’s associated Lua thread or nil if the connection is not a Lua connection or the thread belongs to another Lua instance (corescript state, etc.)