1

This is not a question but can someone explain to me what does a pcall do?

..................................................................

1

I will attempt this question, my info might not be 100% accurate, but here’s what I know.

pcall stands for protected call, errors that happen in a pcall will not yield the rest of the script. It is commonly used when getting data, such as DataStore or HTTPService.

With pcall, Both print() will run:

print('before gibberish')

pcall(function()
insert gibberish that errors
end)

print('after gibberish')


Without pcall, First print() runs, second print() doesn’t:

print('before gibberish')

insert gibberish that errors

print('after gibberish')


You can also get the error message and if the code inside pcall actually error’d.

local success, response = pcall(function()
gibbersh stuf
end)

if not success then
print(response) --print error / response
else
print('no error / response')
end