All different types of prints?

What are all the different things similar to print?

The only ones I know are print and warn

print('Hello world')

warn('Hello world')

error('Hello world')

game:GetService('TestService'):Message("Hello world")

Any more?

EDIT: Added stuff to the list

6 Likes

error("blah")

Those are the three. I guess assert too, but that’s more indirect

5 Likes

Many of the TestService functions will also print into the console when used.

5 Likes

Fyi the error function kills the executing thread. If you want to push red text to the output without killing the thread, you might be able to achieve that with spawn()ing a thread to do it, but I’m not sure.

2 Likes

Looks like this is also a thing

game:GetService('TestService'):Message("Hello world")

Anyone know how to print raw blue text?

I guess you could do

game:GetService('TestService'):Message("\nexample")

but that will still say “TestService:”

1 Like

A post was merged into an existing topic: Off-topic and bump posts

cough

Colors in the output window

6 Likes

Is there any reason to use any of these over print?

Absolutely, I use these regularly in my code bases.

Suppose you define a method in a module somewhere that can be publicly accessed and takes some arguments, and cannot work properly if the arguments have the wrong type, then it’s nice to first check the types of the arguments and to use ‘error’ to throw an error and stop the current thread. This will give you a nice stack trace in output that you can use to easily fix the issue (and you can give it a descriptive error message). This is better than your code erroring in the body of that function a bit later (i.e. because it expects a different type and then starts doing like mathematical operations on strings, or similar) because in the latter situation you need to spend more time tracking backwards to figure out where it exactly went wrong.

For ‘warn’, you can use this in situations where the script can technically continue normally, but the situation that is encountered is weird and something that should probably be looked into. For example, if you are using WaitForChild with a timeout to wait for a particle effect, but then that particle effect cannot be found within the timeout (WaitForChild returns nil), you might want to throw a warning “Particle was not played because it could not be found”, so that you are informed of this event and can look into it.

4 Likes

The last output message type is the Confiential type, which is colored purple. Confidential output messages do not get sent to the LogService, so they cannot be seen in the Developer Console. They are only visible in Roblox Studio’s output. Currently there is no function available that allows you to print with this message type.

8 Likes