Learn
Engine Library
debug

Summary

Functions
traceback(message: string,level: number):string
traceback(thread: coroutine,message: string,level: number):string
info(level: number,options: string):Tuple
info(function: function,options: string):Tuple
info(thread: coroutine,level: number,options: string):Tuple
profilebegin(label: string):()

API Reference
Functions
traceback
debug.traceback(
message:string, level:number
Parameters
message:string
level:number
Default Value: 1
Returns
Code Samples
Debug Traceback

traceback
debug.traceback(
thread:coroutine, message:string, level:number
Parameters
thread:coroutine
message:string
level:number
Default Value: 1
Returns
Code Samples
Debug Traceback Of A Thread

info
debug.info(
level:number, options:string
Parameters
level:number
options:string
Returns
Code Samples
Debug Info By Level

info
debug.info(
function:function, options:string
Parameters
function:function
options:string
Returns
Code Samples
Debug Info By Function

info
debug.info(
thread:coroutine, level:number, options:string
Parameters
thread:coroutine
level:number
options:string
Returns
Code Samples
Debug Info By Thread

profilebegin
debug.profilebegin(label:string):()
Parameters
label:string
Returns
()
Code Samples
Debug Profile Begin
local function buildGrid(size)
debug.profilebegin("BuildGrid")
local grid = table.create(size * size, 0)
debug.profileend()
return grid
end
print(#buildGrid(32)) --> 1024

profileend
debug.profileend():()
Returns
()
Code Samples
Debug Profile End
debug.profilebegin("Outer")
debug.profilebegin("Inner")
-- Work done here is timed under both labels
debug.profileend() -- closes "Inner"
debug.profileend() -- closes "Outer"

getmemorycategory
debug.getmemorycategory():string
Returns
Code Samples
Debug Get Memory Category
local category = debug.getmemorycategory()
print(type(category)) --> string
-- The category follows the thread, so a new one can differ from this one
local previous = debug.setmemorycategory("Pathfinding")
print(debug.getmemorycategory()) --> Pathfinding
debug.setmemorycategory(previous)

setmemorycategory
debug.setmemorycategory(tag:string):string
Parameters
tag:string
Returns
Code Samples
Debug Set Memory Category
local original = debug.setmemorycategory("MapGeneration")
print(debug.getmemorycategory()) --> MapGeneration
-- Allocations made here are listed under "MapGeneration" in the Developer Console
local tiles = table.create(1000, 0)
-- The return value is the previous category, so it can be restored
print(debug.setmemorycategory(original) == "MapGeneration") --> true

resetmemorycategory
debug.resetmemorycategory():()
Returns
()
Code Samples
Debug Reset Memory Category
local automatic = debug.getmemorycategory()
debug.setmemorycategory("Spawning")
print(debug.getmemorycategory()) --> Spawning
debug.resetmemorycategory()
print(debug.getmemorycategory() == automatic) --> true

dumpcodesize
debug.dumpcodesize():()
Returns
()
Code Samples
Debug Dump Code Size
-- debug.dumpcodesize() only works from the Studio Command Bar, where it prints a
-- report to the Output with one table per native script, largest functions first:
-- # Native Code Size Analysis
-- <n> scripts, <n> functions, <n> KB memory, 256 MB code size limit
-- ## <script name>
-- <n> functions, <n> KB memory
-- | Function | Line | Native Code Size | Native Code Size (%) |
-- Only scripts that start with --!native and have run appear in the report.
-- From a Script it raises an error, which pcall catches
local ok, message = pcall(debug.dumpcodesize)
print(ok) --> false
print(message) --> dumpcodesize can only be called from CommandBar

©2026 Roblox Corporation. Roblox, the Roblox logo and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.