Is it possible if when a script errors it triggers a Bindable Event
✓ ANSWER ACCEPTED
Detecting if a script errors?
1 answer
✓ Accepted answer
Yes, by wrapping your code in pcall:
function runCode()
--your code here
end
if pcall(runCode) then
--No error!
else
--It errored...
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
okay thanks :D
You mean
pcall(runCode)? Also, I think in generalypcallshould be preferredOh that's useful. It's like a Lua try catch. Is there anyway to use the exception as an argument? In Java try{SOME_CODE;}catch(SOME ERROR){SOME_OTHER_CODE;}
@DewnOracle: The second return value of
pcallis the error message (as a string). You can usexpcallto get a bit more fine-tuned error handling by passing a function to run (in the erroring scope)That typo is the reason I prefer anonymous functions to doing this. Yeah, ypcall is probably better if the function yields.