Skip to content

Closures

The Closures library enables the inspection, modification and creation of Luau closures with precise control.

It is one of the most powerful tools available, exposing internals in a way that Luau does not natively support out of the box.

This library is incredibly useful for hooking functions to modify game logic to your own advantage, and any other creative uses you can think of.


What is a closure?

The term "closure" comes from functional programming and refers to a function plus the environment it carries (its upvalues).

In Luau (and Lua), every function is implemented as a closure implicitly, even if it doesn't capture anything.


What can you do?

With the Closures library, you can:


What can't you do?

Although closure capabilities are powerful, there are natural boundaries:

  • You cannot inspect true C closures' internals - they are not Lua-defined, compiled, and therefore opaque by design.
  • Attempting to implement newcclosure in Lua (e.g. via coroutine.wrap) will fail sUNC verification.