How to Print a Stack Trace in Blue Text

Few days ago, I’ve noticed that when calling instance:FindFirstChild(number) , a warning is generated with a full stack trace. This trace indicates the specific line of code that called the FindFirstChild function with incorrect parameter types.

I’m interested in achieving a similar result. I have tried using print(debug.traceback()) to print the traceback, but this results in standard print text.

What I’m looking for is a way to print the stack trace in blue text, similar to the warning generated by FindFirstChild.

Thank you in advance for your help!

you could just do error(), so you can get the stack trace, but it will also show the red error text

But that would also stop the script running :confused:, we want the script running as normal.

Yeah, you can’t print it in blue (REFER TO POST 6). traceback() is your best bet.

Assuming :FindFirstChild() still does the outputting, this could work:

You could make a function that just contains the following:

function Traceback(Error)
   warn("An error occured:", Error)
    script:FindFirstChild(15905)
end

if 0.1 + 0.2 == 0.3 then
    print("All is well")
else
    Traceback("Computer maths is broken")
end

not ideal, but does the job

debug.traceback()
if no one did notice, that’s the intended way to do it.

@addisonshiu

You can print in blue via TestService:Message(), it’s prefixed with “TestService:” but there’s no way to get around it

I felt like there was something that allowed you to do that, and kinda just assumed I was recalling something from a feature request when it didn’t show up in the debug library. I’ll look around in TestService later lol.