"pcall()" Coding Meaning

So I was coding a DataStore system on some Roblox Test Games, but I dont know what does “pcall()” means, could someone tell me please what does that means? I tried searching on the DevHub but I dont find it anywhere.

When you get an error on a script the script will stop working, so what pcall basically does is to ignore the error and let the code run:


Now, this can be stored in 2 variables like on a DataStore, success means that it didn’t find any errors and errorMessage gives an error message if the DataStore didn’t worked correctly.

local success, errorMessage = pcall(function()

if success then

pcall and xpcall are very similar, and they prevent errors

also there used to be a ypcall right?

pcall is short for Protected Call, it’s a way to run a function without it stopping the script if it errors.

It returns 2 things, if the function ran without errors or not (true or false) and the result the function gives or the error string if it errored

You can read up on this if you want to learn more about pcall


Please use a simple Google search before posting, all the information below is available on the Lua Globals API page. A pcall() is a protected call, meaning that the function is run in protected mode and any errors do not affect the main code. It takes two arguments, func which is a function and args which is a tuple. It returns a status code (boolean) indicating whether or not there was an error. If it was a success then it returns all the results from the call, if it was not a success then it returns the error message.

I’d just like to add that pcall() stands for “protective call.”

There are a handful of functions like pcall that are abbreviated. Using Google or whatever to unabbreviate will be your new bestfriend.