Marks a function so its call frames are skipped by stack-walking functions. When hidden, the function does not appear to getfenv, debug.info, debug.traceback and related level-based inspection, so code probing the stack sees the game’s frames rather than yours.

Parameters

function | number
required
The function to hide, or a stack level resolving to a function currently on the stack. Level 0 is the calling function, 1 its caller, and so on.
boolean
required
true to hide the function’s frames, false to stop hiding them.

Behavior

  • Hiding is per-function and persistent until you set it back to false.
  • When any function is hidden, the environment’s stack-level accounting transparently skips hidden frames, so a script calling getfenv(2) or debug.info(2, ...) counts visible frames only.
  • Passing a level resolves the function at that level once, at call time, and hides that function.
One thing to keep in mind: hiding frames changes what level-based functions observe. If your own code also leans on stack levels while something is hidden, account for the shift.

Example

Hide the current function’s frames from anything that inspects the stack:

Errors