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.
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
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