Yuari
Documentation
Docs/Debug/debug.setname

debug.setname

Sets the debug name of a function.

Syntax

debug.setname(fn: function, name: string) -> nil

Parameters

ParameterTypeDescription
fnfunctionThe function or callback to use.
namestringThe name used for the lookup or new object.

Returns

TypeDescription
nilThis function does not return a value.

Description

debug.setname is part of the Debug library. The debug library exposes the internals of the active Luau state, including protos, constants, upvalues and stack frames.

The change is applied directly to the live target, so later reads observe the updated value.

The aliases setname(fn, name) resolve to the same implementation.

Example

local fn = function() end
debug.setname(fn, "CustomName")
print(debug.info(fn, "n"))

Notes

  • Aliases: setname(fn, name).
  • Writing protos, constants or upvalues can corrupt a running function; test changes carefully.