Skip to content

getnamecallmethod

This function returns the active __namecall method, whether or not that metamethod is hooked. It returns nil when no namecall method is available.

getnamecallmethod returns the name of the method that invoked the __namecall metamethod.

It retrieves the method being called (e.g. InvokeServer) from the current __namecall invocation. This works both in a normal __namecall metamethod and in a hookmetamethod hook targeting __namecall.

When no namecall method is available, this function will safely return nil.

function getnamecallmethod(): string?

Parameters

Parameter Description
(none) This function takes no parameters.

Example

Disallowing the usage of game:service()
local refs = {}

refs.__namecall = hookmetamethod(game, "__namecall", function(...)
    local self = ...
    local method = getnamecallmethod()

    if self == game and method == "service" then
        error("Using game:service() is not allowed.")
    end

    return refs.__namecall(...)
end)