Skip to main content

runtime

Library

Contains functions that modify the Lua(u) Virtual Machine runtime.

Functions

disablenative

runtime.disablenative(
fn(T...) → U...--

The function to disable native code execution for.

) → ()

Disables the execution of native generated code for the provided function.

Hooking functions

You may need to call this function in the future before hooking functions!

Example

-- This signals the compiler to enable native code generation on the protos the main proto contains!
-- This means herein if the LVM supports native code, it will be enabled for the functions the code has (and if the compiler believes it to be 'benefitial'!)
--!native 

local function a()
    local function b()
        print("hi b")
        print(runtime.isnativecode(a)) -- true
        print(runtime.isnativecode(b)) -- true
        runtime.disablenative(debug.info(1, "f")) -- entry point is now bytecode, should be able to be restored without limitations.
        runtime.disablenative(debug.info(2, "f")) -- entry point is now bytecode, should be able to be restored without limitations.
        print(runtime.isnativecode(a)) -- false
        print(runtime.isnativecode(b)) -- false
    end
    print("hi a")
    b()
end

-- Uncomment if you remove --!native
-- runtime.enablenative(a)
a()
Implementation

Depending on your implementation, you may be unable to remove native code from a function that is on the callstack currently. Investigate into the CodeGen implementation to learn how to do things properly.

Errors

TypeDescription
VM is not supportedThe VM does not support native code.

enablenative

runtime.enablenative(
fn(T...) → U...--

The function to enable native code execution for.

) → ()

Enables the execution of native generated code, if the Lua(u) VM is prepared for it.

Errors

TypeDescription
VM is not supportedThe VM does not support native code.

isnativecode

runtime.isnativecode(
fn(T...) → U...--

The function to check.

) → boolean--

Whether the function is implemented in native code or running with a native code implementation.

Checks if the current function is implemented in the form of native code (implemented in C or runs with generated native code).

can_vm_run_native_code

runtime.can_vm_run_native_code() → boolean--

Whether the VM can run native code.

Checks if the current Lua(u) VM can run native code.

getstringatom

runtime.getstringatom(
strstring--

The string to get the atom of.

) → number--

The atom of str, as a signed 16 bit integer (short/I16/std::int16_t).

Obtains the 'atom' of the given string str.

getstringhash

runtime.getstringhash(
strstring--

The string to get the hash of.

) → number--

The hash of str, as an unsigned integer.

Obtains the hash of the given string str that was assigned to it by Lua(u).

enablepointerencoding

runtime.enablepointerencoding() → ()

Enables pointer encoding for the Lua(u) VM.

Implementation

This function should be implemented as a way to restore the pointer encryption key to the original value, using the key that RBX::ScriptContext contains. While any value is acceptable, it is recommended to use the value from RBX::ScriptContext in order to avoid issues.

disablepointerencoding

runtime.disablepointerencoding() → ()

Disables pointer encoding for the Lua(u) VM.

Executor Development

This can help locate objects in memory to find out about their true structure in memory.

getrawaddress

runtime.getrawaddress(
objany--

The object to retrieve the address of.

) → string--

The raw address.

Gets the raw address of the provided value using topointer.

isinstance

runtime.isinstance(
objuserdata--

The object to check.

) → boolean--

Whether the object is a userdata of type Instance.

Returns whether the given object is a userdata of type Instance.

Implementation

This function should NEVER be implemented as a __type check. You must figure out a way to do it yourself.

getuserdatatag

runtime.getuserdatatag(
objuserdata--

The object which inherits from userdata.

) → number--

The userdata tag of the object.

Returns the userdata tag for the provided object.

setluaufflag

runtime.setluaufflag(
flagNamestring,--

The name of the flag to set.

flagValueboolean--

The value to set the flag to.

) → ()

Sets a fast flag in the Lua(u) VM for specific behaviour.

Implementation

This functions should affect the Roblox VM as well if you are using a RVM/CLVM execution method.

disableerrorlogging

runtime.disableerrorlogging() → ()

Disables the error logging Roblox does on the VM. This is NOT the same as disabling error logging in the VM itself, it simply disables the ScriptContext.Error signal.

Implementation

This function can be implemented using hooksignal or getconnections, but it must continue to work even if new connections are added to the event.

enableerrorlogging

runtime.enableerrorlogging() → ()

Enables the error logging Roblox does on the VM. This is NOT the same as disabling error logging in the VM itself, it simply enables the ScriptContext.Error signal again after being disabled.

getrbxbuildhash

Optional
runtime.getrbxbuildhash() → string--

The ROBLOX build hash.

Returns the Version hash of the current, running ROBLOX version. The version hash is the hash that follows the 'version' string in version-....

gethwid

runtime.gethwid() → string--

The hash of your tool's calculated HWID, as a hex string.

Returns the HWID for the running computer.

HWID Hashing

After performing your own tool's HWID calculations, you are expected to provide a hex-formatted hash that cannot be reconstructed back to the original HWID.

checkcaller

runtime.checkcaller() → boolean--

Whether the current thread was created by the executor.

Returns whether the current thread was created by the executor.

getnamecallmethod

runtime.getnamecallmethod() → string?--

The namecall method, if nil, there is no namecall set.

Returns the current namecall method.

setnamecallmethod

runtime.setnamecallmethod(
newNamecallstring--

The namecall method to set.

) → string?--

The namecall method, if nil, there is no namecall set.

Sets the current namecall method.

Errors

TypeDescription
no namecall currentlyThere is no namecall currently occurring.

getthreadidentity

runtime.getthreadidentity(
ththread?--

The thread to get the identity of (if nil, defaults to current thread)

) → number--

The thread identity of the current thread (or given thread)

Gets the current thread identity and capabilities.

setthreadidentity

runtime.setthreadidentity(
threadIdentitynumber--

The thread identity to set. Must be between 0 and 8

) → ()

Sets the current thread identity and capabilities.

setfpscap

runtime.setfpscap(
fpsnumber?--

The maximum amount of frames per second (fps). If no value is provided, it automatically defaults to 1000.

) → ()

Sets the maximum amount of frames per second (fps) to run the game engine can run at.

Implementation

This function should set the FPS to 1000 if the valueo of fps is 0.

Errors

TypeDescription
invalid fps valueThe fps value is invalid, i.e., it is less than 0

getfpscap

runtime.getfpscap() → number--

The current target FPS of the game engine.

Sets the maximum amount of frames per second (fps) to run the game engine can run at.

rubisload

Optional
runtime.rubisload() → ((() → ()) | nil),string?--

The closure that was loaded, if successful, or nil if it failed with a second string return.

Loads a scrap from the Rubis API.

TIP

This is simply loadstring, but specific towards the Rubis API.

getbytecode

Optional
runtime.getbytecode(
luauCodestring--

The Luau code to get the bytecode of.

) → string--

The bytecode of the given Luau code.

Returns the bytecode of the given Luau code.

decompile

Optional
runtime.decompile(
luauBytecodeOrScriptLuaSourceContainer | string--

The Luau bytecode or script to decompile.

) → string--

The decompiled Luau bytecode.

Decompiles the given Luau bytecode or script.

disassemble

Optional
runtime.disassemble(
luauBytecodeOrScriptLuaSourceContainer | string--

The Luau bytecode or script to decompile.

) → string--

The disassembled Luau bytecode.

Disassembles the given Luau bytecode or script.

setcalltrace

Optional
runtime.setcalltrace(
isEnabledboolean--

Whether to enable call tracing.

) → boolean

Allows you to trace execution calls to diagnose a crash.

Show raw api
{
    "functions": [
        {
            "name": "disablenative",
            "desc": "Disables the execution of native generated code for the provided function.\n\n:::tip Hooking functions\nYou may need to call this function in the future before hooking functions!\n:::\n    \n\n### Example\n```lua\n-- This signals the compiler to enable native code generation on the protos the main proto contains!\n-- This means herein if the LVM supports native code, it will be enabled for the functions the code has (and if the compiler believes it to be 'benefitial'!)\n--!native \n\nlocal function a()\n    local function b()\n        print(\"hi b\")\n        print(runtime.isnativecode(a)) -- true\n        print(runtime.isnativecode(b)) -- true\n        runtime.disablenative(debug.info(1, \"f\")) -- entry point is now bytecode, should be able to be restored without limitations.\n        runtime.disablenative(debug.info(2, \"f\")) -- entry point is now bytecode, should be able to be restored without limitations.\n        print(runtime.isnativecode(a)) -- false\n        print(runtime.isnativecode(b)) -- false\n    end\n    print(\"hi a\")\n    b()\nend\n\n-- Uncomment if you remove --!native\n-- runtime.enablenative(a)\na()\n```\n\n:::danger Implementation\nDepending on your implementation, you may be unable to remove native code from a function that is on the callstack currently. Investigate into the CodeGen implementation to learn how to do things properly.\n:::",
            "params": [
                {
                    "name": "fn",
                    "desc": "The function to disable native code execution for.",
                    "lua_type": "(T...) -> U..."
                }
            ],
            "returns": [],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "VM is not supported",
                    "desc": "The VM does not support native code."
                }
            ],
            "source": {
                "line": 49,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "enablenative",
            "desc": "Enables the execution of native generated code, if the Lua(u) VM is prepared for it.",
            "params": [
                {
                    "name": "fn",
                    "desc": "The function to enable native code execution for.",
                    "lua_type": "(T...) -> U..."
                }
            ],
            "returns": [],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "VM is not supported",
                    "desc": "The VM does not support native code."
                }
            ],
            "source": {
                "line": 58,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "isnativecode",
            "desc": "Checks if the current function is implemented in the form of native code (implemented in C or runs with generated native code).",
            "params": [
                {
                    "name": "fn",
                    "desc": "The function to check.",
                    "lua_type": "(T...) -> U..."
                }
            ],
            "returns": [
                {
                    "desc": "Whether the function is implemented in native code or running with a native code implementation.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 67,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "can_vm_run_native_code",
            "desc": "Checks if the current Lua(u) VM can run native code.",
            "params": [],
            "returns": [
                {
                    "desc": "Whether the VM can run native code.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 77,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getstringatom",
            "desc": "Obtains the 'atom' of the given string `str`.",
            "params": [
                {
                    "name": "str",
                    "desc": "The string to get the atom of.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The atom of str, as a signed 16 bit integer (short/I16/std::int16_t).",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 89,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getstringhash",
            "desc": "Obtains the hash of the given string `str` that was assigned to it by Lua(u).",
            "params": [
                {
                    "name": "str",
                    "desc": "The string to get the hash of.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The hash of str, as an unsigned integer.",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 101,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "enablepointerencoding",
            "desc": "Enables pointer encoding for the Lua(u) VM.\n\n\n:::info Implementation\nThis function should be implemented as a way to restore the pointer encryption key to the original value, using the key that RBX::ScriptContext contains.\nWhile any value is acceptable, it is recommended to use the value from RBX::ScriptContext in order to avoid issues.\n:::",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 115,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "disablepointerencoding",
            "desc": "Disables pointer encoding for the Lua(u) VM.\n\n\n:::tip Executor Development\nThis can help locate objects in memory to find out about their true structure in memory.\n:::",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 126,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getrawaddress",
            "desc": "Gets the raw address of the provided value using `topointer`.",
            "params": [
                {
                    "name": "obj",
                    "desc": "The object to retrieve the address of.",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The raw address.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 137,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "isinstance",
            "desc": "Returns whether the given object is a userdata of type Instance.\n\n\n:::warning Implementation\nThis function should **NEVER** be implemented as a __type check. You must figure out a way to do it yourself.\n:::",
            "params": [
                {
                    "name": "obj",
                    "desc": "The object to check.",
                    "lua_type": "userdata"
                }
            ],
            "returns": [
                {
                    "desc": "Whether the object is a `userdata` of type `Instance`.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 153,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getuserdatatag",
            "desc": "Returns the userdata tag for the provided object.",
            "params": [
                {
                    "name": "obj",
                    "desc": "The object which inherits from userdata.",
                    "lua_type": "userdata"
                }
            ],
            "returns": [
                {
                    "desc": "The userdata tag of the object.",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 165,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "setluaufflag",
            "desc": "Sets a fast flag in the Lua(u) VM for specific behaviour.\n\n\n:::info Implementation\nThis functions should affect the Roblox VM as well if you are using a RVM/CLVM execution method.\n:::",
            "params": [
                {
                    "name": "flagName",
                    "desc": "The name of the flag to set.",
                    "lua_type": "string"
                },
                {
                    "name": "flagValue",
                    "desc": "The value to set the flag to.",
                    "lua_type": "boolean"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 181,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "disableerrorlogging",
            "desc": "Disables the error logging Roblox does on the VM. This is **NOT** the same as disabling error logging in the VM itself, it simply disables the `ScriptContext.Error` signal.\n\n\n:::info Implementation\nThis function can be implemented using `hooksignal` or `getconnections`, but it must continue to work ***even*** if new connections are added to the event.\n:::",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 192,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "enableerrorlogging",
            "desc": "Enables the error logging Roblox does on the VM. This is **NOT** the same as disabling error logging in the VM itself, it simply enables the `ScriptContext.Error` signal again after being disabled.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 198,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getrbxbuildhash",
            "desc": "Returns the Version hash of the current, running ROBLOX version. The version hash is the hash that follows the 'version' string in `version-...`.",
            "params": [],
            "returns": [
                {
                    "desc": "The ROBLOX build hash.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "tags": [
                "Optional"
            ],
            "source": {
                "line": 207,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "gethwid",
            "desc": "Returns the HWID for the running computer.\n\n\n:::danger HWID Hashing\nAfter performing your own tool's HWID calculations, you are expected to provide a hex-formatted hash that cannot be reconstructed back to the original HWID.\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "The hash of your tool's calculated HWID, as a hex string.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 221,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "checkcaller",
            "desc": "Returns whether the current thread was created by the executor.",
            "params": [],
            "returns": [
                {
                    "desc": "Whether the current thread was created by the executor.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 231,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getnamecallmethod",
            "desc": "Returns the current namecall method.",
            "params": [],
            "returns": [
                {
                    "desc": "The namecall method, if nil, there is no namecall set.",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 241,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "setnamecallmethod",
            "desc": "Sets the current namecall method.",
            "params": [
                {
                    "name": "newNamecall",
                    "desc": "The namecall method to set.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The namecall method, if nil, there is no namecall set.",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "no namecall currently",
                    "desc": "There is no namecall currently occurring."
                }
            ],
            "source": {
                "line": 253,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getthreadidentity",
            "desc": "Gets the current thread identity and capabilities.",
            "params": [
                {
                    "name": "th",
                    "desc": "The thread to get the identity of (if nil, defaults to current thread)",
                    "lua_type": "thread?"
                }
            ],
            "returns": [
                {
                    "desc": "The thread identity of the current thread (or given thread)",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 264,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "setthreadidentity",
            "desc": "Sets the current thread identity and capabilities.",
            "params": [
                {
                    "name": "threadIdentity",
                    "desc": "The thread identity to set. Must be between 0 and 8",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 274,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "setfpscap",
            "desc": "Sets the maximum amount of frames per second (fps) to run the game engine can run at.\n\n\n:::info Implementation\nThis function should set the FPS to 1000 if the valueo of `fps` is 0.\n:::",
            "params": [
                {
                    "name": "fps",
                    "desc": "The maximum amount of frames per second (fps). If no value is provided, it automatically defaults to 1000.",
                    "lua_type": "number?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "invalid fps value",
                    "desc": "The fps value is invalid, i.e., it is less than 0"
                }
            ],
            "source": {
                "line": 287,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getfpscap",
            "desc": "Sets the maximum amount of frames per second (fps) to run the game engine can run at.",
            "params": [],
            "returns": [
                {
                    "desc": "The current target FPS of the game engine.",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 295,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "rubisload",
            "desc": "Loads a scrap from the Rubis API.\n\n\n:::tip \nThis is simply `loadstring`, but specific towards the Rubis API.\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "The closure that was loaded, if successful, or nil if it failed with a second string return.",
                    "lua_type": "((() -> ()) | nil), string?"
                }
            ],
            "function_type": "static",
            "tags": [
                "Optional"
            ],
            "source": {
                "line": 310,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "getbytecode",
            "desc": "Returns the bytecode of the given Luau code.",
            "params": [
                {
                    "name": "luauCode",
                    "desc": "The Luau code to get the bytecode of.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The bytecode of the given Luau code.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "tags": [
                "Optional"
            ],
            "source": {
                "line": 322,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "decompile",
            "desc": "Decompiles the given Luau bytecode or script.",
            "params": [
                {
                    "name": "luauBytecodeOrScript",
                    "desc": "The Luau bytecode or script to decompile.",
                    "lua_type": "LuaSourceContainer | string"
                }
            ],
            "returns": [
                {
                    "desc": "The decompiled Luau bytecode.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "tags": [
                "Optional"
            ],
            "source": {
                "line": 334,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "disassemble",
            "desc": "Disassembles the given Luau bytecode or script.",
            "params": [
                {
                    "name": "luauBytecodeOrScript",
                    "desc": "The Luau bytecode or script to decompile.",
                    "lua_type": "LuaSourceContainer | string"
                }
            ],
            "returns": [
                {
                    "desc": "The disassembled Luau bytecode.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "tags": [
                "Optional"
            ],
            "source": {
                "line": 346,
                "path": "impl/Libraries/runtime.luau"
            }
        },
        {
            "name": "setcalltrace",
            "desc": "Allows you to trace execution calls to diagnose a crash.",
            "params": [
                {
                    "name": "isEnabled",
                    "desc": "Whether to enable call tracing.",
                    "lua_type": "boolean"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\r\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Optional"
            ],
            "source": {
                "line": 357,
                "path": "impl/Libraries/runtime.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "runtime",
    "desc": "Contains functions that modify the Lua(u) Virtual Machine runtime.",
    "tags": [
        "Library"
    ],
    "source": {
        "line": 7,
        "path": "impl/Libraries/runtime.luau"
    }
}