Hello,
I have been looking for the meaning on ‘pcall function’ on the wiki and I can’t find the meaning. So if you could tell me the meaning and what it is used for I would be grateful.
Thanks!
Hello,
I have been looking for the meaning on ‘pcall function’ on the wiki and I can’t find the meaning. So if you could tell me the meaning and what it is used for I would be grateful.
Thanks!
Pcalls are used in stuff like :GetAsync, :SetAsync, :UpdateAsync because it prevents a error from destroying the whole script.
Say :GetAsync fails, it puts a error in the output. The whole script would of just stopped because of that error, but if u were to put a pcall it wont throw a error and the script will continue.
Although it doesn’t re-run the script, it only continues the script.
pcall = protected call, that means that if the code inside of that function errors, the script doesnt break but instead reuturn error message
Basically, when you don’t know whether would a function succeed, or return an error. You use pcall(), so when it returns an error, the code downward still work normally without stopping. Mostly known for being used with datastore-related stuff.
pcall function is useful to see if the code has an error and if it has it says in the output
Thanks everyone, I was struggling with understanding, really helped me thanks!