Volt

getnamecallmethod

Gets the method name being called in a __namecall hook.

Syntax

getnamecallmethod() -> string

Returns

TypeDescription
stringThe method name being called

Description

getnamecallmethod returns the name of the method being called when inside a __namecall metamethod hook. This is essential for filtering which method calls to intercept.

Example

local oldNamecall
oldNamecall = hookmetamethod(game, "__namecall", newcclosure(function(self, ...)
    local method = getnamecallmethod()
    
    if method == "Kick" then
        return -- Block kick
    end
    
    if method == "FireServer" then
        print("FireServer called on:", self)
    end
    
    return oldNamecall(self, ...)
end))

Common Methods to Hook

MethodObjectDescription
FireServerRemoteEventClient to server communication
InvokeServerRemoteFunctionClient to server with return
KickPlayerKick the player
DestroyInstanceDestroy an instance
GetServiceServiceProviderGet a service

Filtering Example

local blockedMethods = {"Kick", "Ban", "Disconnect"}

oldNamecall = hookmetamethod(game, "__namecall", newcclosure(function(self, ...)
    local method = getnamecallmethod()
    
    if table.find(blockedMethods, method) then
        warn("Blocked:", method)
        return
    end
    
    return oldNamecall(self, ...)
end))

Notes

  • Only works inside __namecall hooks
  • Returns the exact method name as a string
  • Case-sensitive

On this page