This library provides a few basic functions for debugging code in Roblox. Unlike the
debug library found in Lua natively, this version has been heavily sandboxed. Roblox does, however, have debugging functionality similar to Lua’s native debugging functionality (see the
|string debug.traceback ( string message, number level = 1 )|
Returns a traceback of the current function call stack as a string. In other words, a description of the functions that have been called up to this point. The
During debugging, debug.traceback answers the question “how did my code get here?” much like an error stack trace, but without stopping the execution of the script. See the example below with several function calls: c() calls b(), b() calls a(), and a() calls debug.traceback.
local function a() print(debug.traceback("Specific moment during a()")) end local function b() a() end local function c() b() end a()
The above code would produce an output similar to (but not guaranteed to be exactly like) the following:
Specific moment during a() ServerScriptService.Script:2 function a ServerScriptService.Script:6 function b ServerScriptService.Script:10 function c ServerScriptService.Script:13
The format of the returned traceback is not defined and may change at any time; use only for debug diagnostics and error analytics. It’s recommended that you never parse the return value of this function for specific information, such as script names or line numbers.
|void debug.profilebegin ( string label )|
Opens a microprofiler label.
|void debug.profileend ( )|
Closes the top microprofiler label.