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

What is pcall?

Asked by 8 years ago

I was wondering if someone can explain to me what pcall is used for, like what does it do?

2 answers

Log in to vote
1
Answered by 8 years ago

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!!!")
Ad
Log in to vote
2
Answered by 8 years ago

More Information on PCall

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.

0
Thanks. ISellCows 2 — 8y

Answer this question