Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't pcall always used for functions?

Since pcall is used to prevent errors why isn't it always used? What are the disadvantages?

1 comment

0

AFAIK, it's sometimes extraneous to add pcall to some areas of the script you know will never crash/error. There are parts in the script that can crash, but can be fixed to handle these scenarios w/o pcalling (usually with if statements), and there are other parts where you just can't account for every error case.

2 answers

✓ Accepted answer

pcall does not really have disadvantages, but people just find it to be excess when using in every function they use (ex: you have a touched function that works, you would not need pcall for it).

As such, pcall is mostly used for Datastore, because it is much more ethical in that field of functions. But there are cases that people use them in other functions, so feel free to use your preference, albeit not recommended,

You are not supposed to write code that can error. The only places you should be using pcall is when you're experimenting with stuff or using any HTTP or third-party API and don't have control over the other end.

This discussion is preserved as it was. New answers, comments, and votes are closed.