getnamecallmethod
Gets the method name being called in a __namecall hook.
Syntax
getnamecallmethod() -> stringReturns
| Type | Description |
|---|---|
string | The 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
| Method | Object | Description |
|---|---|---|
FireServer | RemoteEvent | Client to server communication |
InvokeServer | RemoteFunction | Client to server with return |
Kick | Player | Kick the player |
Destroy | Instance | Destroy an instance |
GetService | ServiceProvider | Get 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
__namecallhooks - Returns the exact method name as a string
- Case-sensitive