How would I get if the outputted message is an error/warning?

Using LogService, it looks like I can get the outputted text in the output or DevConsole, and probably using its event:

I can get the type of message that was printed. But, not asking for full scripts, just a start, how would I do that?


You should be able to detect via the MessageType return, as there are 2 types for Warnings and Errors


The article you provided also gives an example as to how you could use the event, you can probably test it out by trying this script out somewhere such as ServerScriptService

local msg ="Message", workspace)
Game:GetService("LogService").MessageOut:Connect(function(Message, Type)
    msg.Text = "The message was "..Message.." and the type was "..tostring(Type)
print("Hello, World!")
warn("This is a warning")
error("This is an error")

Note that you cannot test it out via printing in the event as that would just make the event loop infinitely


Nice, but I have a question, why would I use tostring, not if Type == 2, for example?

EDIT: I see the tostring is for text, thanks, but what I said upper would work?

I believe tostring was used in this case an example to put it on text. You can simply do

if Type == Enum.MessageType.MessageWarning then

For warnings and

if Type == Enum.MessageType.MessageError then

For errors

Also yours would not work, you need to compare the .Value of the enum

if Type.Value == 2 then

Would work but

if Type == 2 then

Would not

1 Like

Thanks! A bit confusing since there are 2 ways but still I didn’t know there was a Enum Value for MessageType!

1 Like

They also have a .Name property which is just the name of the Enum itself! The first method is a bit conventional so I’d recommend it more than comparing the value.

If you have anymore issues don’t be afraid to make another post!

1 Like