How do we tell if a script has error'd without using pcall

Just wondering because I’m lazy and don’t feel like implementing pcall into every one of my scripts. Is there something fired whenever a script errors locally which we can then restart the script :smiley:. Like a callback of sort.

1 Like

https://wiki.roblox.com/index.php?title=API:Class/ScriptContext/Error

3 Likes

oof I was just getting the link to post that, but was 60 seconds too late :smile:

1 Like

You shouldn’t be restarting scripts that have errored. If you’re doing an action that can potentially fail, such as a datastore call, then you should wrap it in a pcall and handle the error within the script, rather than restarting the entire script.

11 Likes

Do the hard thing and use pcall where necessary. Any functions with chance of erroring should be wrapped in a pcall and any other code is up to you to debug.

when first reply is just a wiki link lol, but I actually never knew that existed