I was wondering if someone can explain to me what pcall is used for, like what does it do?
✓ ANSWER ACCEPTED
What is pcall?
2 answers
✓ Accepted answer
Here's how to use pcall: (and of course its setup to fail....)
Change NILVALUE to "HI" for fail to be false and get the success message to print .
local NILVALUE = nil
local success, fail = pcall(function()
print("this is a test")
print("Concatenate a value: "..NILVALUE)
end)
if fail then
print("Failure: "..fail) -- your failure reason will be here
return
end
print("we succeeded!!!")
PCall Is a way to check errors in functions without breaking the script. This is widely used for debugging. It has 2 arguements, (true,error) if true is false then error message will be tjhe error in the script.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thanks.