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

What is pcall?

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

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!!!")

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.

1 comment

0

Thanks.

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