checkcaller
Tells a hook who called it: your own script, or the game.
Syntax
checkcaller() -> boolean
Also available as
check_caller
Returns
| Type | Description |
|---|---|
boolean | true when the function was called from code you ran through Apex, false when the game called it. |
Description
Apex decides by the calling thread's globals. Code whose environment leads back to the executor environment counts as yours, and so do functions your script connected to signals, even when the engine later runs them. Everything else, including the game's LocalScripts, ModuleScripts and CoreScripts, counts as the game.
The usual use is inside a hookmetamethod or hookfunction hook, where you want to change what the game sees but leave your own calls alone.
Example
local old
old = hookmetamethod(game, "__namecall", function(self, ...)
if not checkcaller() and getnamecallmethod() == "Kick" then
return nil
end
return old(self, ...)
end)
print(checkcaller())
Notes
- Called at the top level of your script, it always returns
true. - Apex helper frames are skipped, so wrappers made with
newcclosurereport the same answer as the function they wrap.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
