Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

getnamecallmethod

The getnamecallmethod function will return the current method that invoked the latest NAMECALL opcode

function getnamecallmethod(): string
game:GetService("Workspace");
print(getnamecallmethod()) --> GetService
game:FindService("Workspace");
print(getnamecallmethod()) --> FindService

This function is used mainly in __namecall hooks, but it has other use cases.

setnamecallmethod

The setnamecallmethod function will set the method that invoked NAMECALl opcode

function setnamecallmethod(new_method_str: string): ()
local hook: (...any) -> (...any); hook = hookmetamethod(game, "__namecall", function(...: any): ...any
    local self: Instance, second_arg: string = ...;
    if (typeof(self) == "Instance" and self == game and getnamecallmethod() == "GetService" and type(second_arg) == "string" and second_arg == "Workspace") then
        setnamecallmethod("FindService");
        return hook(...);
    end;
    return hook(...);
end);

This function is useful for detouring specific methods that you do not want to be called.

setreadonly

The setreadonly function will set the table’s read-only state to the specified boolean

function setreadonly(arg: {[any]: any}, state: boolean): ()
local silly_table: {[string]: any} = {};
silly_table.hi = "hi";
setreadonly(silly_table, true);
silly_table.hi = "no"; --> errors: Attempt to modify a read only table

This function is useful for being able to protect or unprotect tables from being read-only

makewriteable

The makewriteable is a short-cut to setreadonly(table, false), this makes the table writable

function makewriteable(arg: {[any]: any}): ()
local wutever: {[any]: any} = {""};
setreadonly(wutever, true);
-- if we modify the table without using `makewriteable` or `setreadonly` the script will error
makewriteable(wutever); --> this is the same as doing setreadonly(wutever, false);
-- we can make changes again
wutever.whatever = ""; --> no error

This function is useful for setting readonly tables to writable states

makereadonly

The makereadonly is a short-cut to setreadonly(table, true) this makes the table read-only

function makereadonly(arg: {[any]: any}): ()
local wutever: {[any]: any} = {""};
makereadonly(wutever);
-- now we can't make changes without the script erroring
wutever.noo = ""; --> errors: Attempt to modify a read only table

This function is useful for setting a table’s read-only state to true

getrawmetatable

The getrawmetatable function will get an object’s metatable similar to getmetatable but will bypass the __metatable protection field.

function getrawmetatable(arg: any): {[string]: any}
local tbl: {[any]: any} = setmetatable({}, {
    __index = function(self: any, index: any): never
        return nil;
    end;
    __metatable = "Locked";
});
print(getmetatable(tbl)) --> prints: "Locked"
print(getrawmetatable(tbl)) --> prints the metatable table

This function is useful if you want to get a metatable of an object that has the __metatable field set Note this function can return __metatable IF the object came from OUTSIDE the VM

setrawmetatable

The setrawmetatable function will set an object’s metatable to the provided table, similar to setmetatable but will bypass the __metatable protection field

function setrawmetatable(arg: any, meta_table: {[string]: any}): {[string]: any}
local tbl: {[any]: any} = setmetatable({}, {
    __index = function(self: any, index: any): never
        return nil;
    end;
    __metatable = "Locked";
});
setrawmetatable(tbl, {});
print(getmetatable(tbl)); --> we can now get the table with getmetatable because we set the metatable to a new metatable without __metatable

This function is useful if you want to set a metatable of an object that has the __metatable field set Note this function can error IF the object came from OUTSIDE the VM

hookmetamethod

The hookmetamethod function will call hookfunction on an object’s metatable with the provided metamethod, if its a function, returning the old function.

function hookmetamethod(arg: any, name_str: string, hook: (...any) -> (...any)): (...any) -> (...any)
local hook: (...any) -> (...any); hook = hookmetamethod(game, "__index", function(...: any): any
    local self: Instance, index: string = ...;
    local result: any = hook(...);
    print(self, index);
    return result;
end);
print(game.Workspace); -- > output: Game, Workspace

This function is useful if you want to hook a metamethod of an object’s metatable, if the metamethod of said object is a function.

Note this function will error if it is called with an object who’s metatable came OUTSIDE of the VM

getgc

The getgc function will return all functions that is stored within the Lua-Garbage-Collector, with an optional argument to include userdatas and tables

function getgc(include_tables_and_userdatas: boolean): {[number]: any}
local function funny_function(): ()
    return;
end;
for _: unknown, v: (...any) -> (...any) in getgc(false) do
    if (type(v) == "function" and islclosure(v) and debug.info(v, "n") == "funny_function") then
        print("found", v);
        break;
    end;
end;

This function is useful if you want to retrieve functions or tables that you do not directly have access to.

getgenv

The getgenv will return the Executor’s Global Environment.

function getgenv(): {[string]: any}
getgenv().hi = true;
print(getgenv().hi); --> true
print(hi) --> true
print(getfenv().hi) --> true

This function is useful for setting constants | states globally from other executed scripts.

getrenv

The ‘getrenv’ function will return Roblox Global Environment, which contain’s task debug os spawn and other globals.

function getrenv(): {[string]: any}
print(debug == getrenv().debug);

This function is useful for resolving name conflicts, (ex. debug in getgenv is not the same as getrenv().debug)

isreadonly

The isreadonly function will return a boolean determining a table’s read-only state.

function isreadonly(arg: {[any]: any}): boolean
local tbl = {};
print(isreadonly(tbl)); --> false
setreadonly(tbl, true);
print(isreadonly(tbl)); --> true

This function is useful if you want to tell if a table is read-only safely.