PcoWSkbVqDnWTu_dm2ix The debug library provides a few basic functions for debugging code in Roblox.

">
We use cookies on this site to enhance your user experience

Jul 02 2018, 3:57 PM PST 2 min

The debug 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. Feel free to take a look at the DebuggerManager class.


Functions


debug.traceback

string debug.traceback()

Description: Returns a traceback of the current stack as a string. The string is identical to the one printed in blue when an error is thrown by a script in Roblox. This function optionally takes

Format

The traceback is divided up into several lines, which are separated using the newline character (\n).
The first line of the traceback is always Stack Begin, and the last line is always Stack End.

The traceback lines between those two lines are formatted as such:
Script '[1]', Line [2] - [3] [4]

[1] - A description of the location where this traceback is being made.
[2] - The line number of the location where this traceback is being made.
[3] - The stack’s type.
[4] - The name of the stack.


debug.profilebegin

void debug.profilebegin(string label)

Description: Opens a microprofiler label.


debug.profileend

void debug.profileend()

Description: Closes the top microprofiler label.