✓ Accepted answer
pcall()
Basically wraps a block of your script, that then when ran, it will catch any errors that might occur, then returning it’s status - which will be a boolean, there are three major common ways that people use pcall,
Method 1:
— If pcall returns true, then it ran successfully, else it returns false, and note that it didn’t run correctly
if pcall(<somefunction>) then
— SUCCESS
else
— ERROR
end
Method 2:
local Status = pcall(<somefunction>)
if Status then
— SUCCESS
else
— ERROR
end
Method 3:
— This time, pcall will edit one of your designated variables to be true, the 1st variable designated - and if it’s true, it means, it ran successfully, else it makes the second designated variable to be true, which means, a error
local suc,err= pcall(<somefunction>)
if suc then
— SUCCESS
elseif err then
— ERROR
end