checkcaller
Returns whether the current function was called by the executor.
function checkcaller(): booleanSynopsis
How it works
Examines the current call stackCall stackThe chain of CallInfo frames representing nested function calls. Each frame records the closure, base register, top, and saved program counter. Walking the call stack reveals the full execution trace. to determine if the immediate caller is executor-owned code. It checks the thread identityThread identityA numeric privilege level (0–8) assigned to each Luau thread. Determines which Roblox APIs are accessible. Identity 2 = LocalScript, 3 = server Script, 6+ = CoreScript/Plugin level. Executors typically use identity 8. and environment of the calling frame — if the caller's
lua_State belongs to the executor's environment rather than a game script, it returns true.VM internals
Each Luau
lua_State has an extraSpace block containing the thread identityThread identityA numeric privilege level (0–8) assigned to each Luau thread. Determines which Roblox APIs are accessible. Identity 2 = LocalScript, 3 = server Script, 6+ = CoreScript/Plugin level. Executors typically use identity 8.. The executor sets its own threads to a known identity level (typically 3+). checkcaller reads the calling frame's thread identity from L->extraSpace->identity and compares it against the executor's range:
// Simplified pseudocode
bool checkcaller(lua_State* L) {
int identity = L->extraSpace->identity;
return identity >= EXECUTOR_IDENTITY_MIN;
}
This is an O(1)O(1)Constant-time complexity — the operation takes the same amount of time regardless of input size. A single hash-table lookup is O(1). operation — one memory read and comparison, no stack traversal needed.Security pattern
The canonical use is guarding hooked functions from game-side probing:
hookfunction(target, newcclosure(function(...)
if not checkcaller() then
return old(...) -- game called it, pass through
end
-- executor called it, do custom logic
end))Usage
Security guard
hookfunction(game.Workspace.FindFirstChild, newcclosure(function(self, name, recursive)
if checkcaller() then
print("Executor called FindFirstChild for:", name)
end
return hookfunction_original(self, name, recursive)
end))Returns
boolean true if the current caller is executor-owned, false otherwise.
Use Case
Ideal for protecting hooked functions from being triggered by untrusted game scripts trying to probe your hooks.