Basically what I am trying to do right now is make a custom log module. I have the basics such as console.log() and console.error(), but I added console.debug() to easily debug scripts, and this requires me to get the script line from debug.traceback(). How would I do this? The string that gets returned is like this: script_hierachy:script_line. Thanks if you can help.
Like you said, the string returned is script_hierarchy:script_line. You can use the string.split function to separate out the script line and script hierarchy appropriately, for example:
This would work technically, though more info may be printed such as the function it was called on like so:
ServerScriptService.Script:2 function a
I’m guessing I could do this?
local splitTraceback = string.split(debug.trackback(), ":")[2]
local line = string.split(splitTraceback, " ")[1]
-- traceback:line info -> line info -> line?
Yep, using split separates everything in-between the character you’re looking for into a table. From what I believe you’re trying to do, you want to do