How do i detect if my script had an error... in my script?

lets say i have a script like this:

local Fart == true.."Fart"

This would give me an error because you cant add a bool and a string together. But how would i check that my script gave out an error?
Something like

script.error:Connect(function()

Im not sure if this exists, but please tell me if it does!

you can use pcall

local suc, err = pcall(function()
--// script
end)

if (err) then 
    warn("script errored")
end

and theres also LogService.MessageOut but that will detect all scripts

game:GetService("LogService").MessageOut:Connect(function(msg, type)
    if (type == Enum.MessageType.MessageError) then 
        warn("error:", msg)
    end
end)

there are a LOT of parts that could if you do specific things could cause an error in my code, ill try the second thing u said later

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.