What is debug tools and how to use them

How do I use the debug tools?

I do not know how to use the debug tools.

I have searched the Developer Hub and DevForum/YouTube but never found out how.

I am a beginner scripter on Lua but I never knew how to use the ‘debug’ tools it always confused me seeing people use them. These debug tools are not as much of a use I heard but I do know I need to know them for certain things. I would love to know how and when to use it so I can have a better career in the future of Roblox Developing.

Debug tools are tools that help you debug scripts by pausing them so you can inspect it while it is running. Ex: the Output Window

But how do I used ones like:

debug.info
debug.profilebegin
debug.profileend
debug.resetmemorycategory
debug.setmemorycategory
debug.traceback

?

Maybe this will help:

I tried looking at it, it didnt help I will try again.

I actually just described 3 of them in another post an hour ago

As for the other functions

profilebegin and profileend create “tags” in the micro profiler which tell you how long a script took to run
image
Here is an image from an example from the “microprofiler” dev tutorial
The “hard work” tag starts with debug.profilebegin() and ends when the debug.profileend() function is called
Here is the script they used in the devforum tutorial

debug.profilebegin("Hard work") -- Start profiling here with this label
-- Example hard work: swap two variables 200,000 times
local a, b = 0, 1
for i = 1, 200000 do
	a, b = b, a
end
debug.profileend() -- Stop profiling here

So the tag basically shows how long something took, starting at profilebegin and ending at profileend

debug.traceback basically just shows all of the functions and scopes which are currently in the environment of the function call

For example

function test()
    print(debug.traceback())
end

Prints:
Workspace.Script:1 function a
Workspace.Script:1

2 Likes

My brain hurts. lol that is really hard. :roblox_light: