Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't pcall always used for functions?

Asked by 5 years ago
Edited 5 years ago

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

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. ScrewDeath 153 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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,

Ad
Log in to vote
0
Answered by
ozzyDrive 670 Moderation Voter
5 years ago

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.

Answer this question