iscclosure
Returns whether the given function is a native C closure.
function iscclosure(func: function): booleanSynopsis
How it works
Checks the Luau type tag of the closureClosureA function value that captures its lexical environment. In Luau, closures come in two types: LClosure (Luau bytecode + Proto + upvalues) and CClosure (native C function pointer + upvalues).'s internal struct. Luau closures have type
LUA_TFUNCTION but two subtypes: LClosure (Luau bytecodeBytecodeThe compiled binary representation of Luau source code. A sequence of 32-bit instructions (opcodes + operands) stored in a Proto's code[] array. Executed by the Luau VM interpreter.) and CClosure (native C). This function returns true if the closure is a CClosure — meaning it was created from a lua_CFunction pointer.What returns true
- Built-in Roblox methods (
print,warn,error) - Standard library functions (
math.abs,string.find) newcclosure-wrapped functions- C functions registered by the executor
Usage
Check closure type
print(iscclosure(print)) "cc">--> true
print(iscclosure(function() end)) "cc">--> false
print(iscclosure(newcclosure(function() end))) "cc">--> trueParameters
func function The function to inspect.
Returns
boolean true if the function is a C closure.