0

# Is there a wiki page for pcall(function()?

I like to read random code in my free time and try to learn new things. Is there a wiki page for this line:

pcall(function()


If there isnt a wiki page could somebody give me a rundown of this line :)

2

There is a wiki here

But I'll still explain (like I always do)

pcall is to catch errors, wich means that if your script would error, pcall will tell you that error, and just continue with the script.

This is very handy for things like datastore and remote functions.

You can make a pcall function like this

function apple()
print('apple')
end

local success, message = pcall(apple) -- DO NOT ADD '()' AFTER THE FUNCTION!!

if success then
else
end


If you did for example this

function apple()
prit('apple')
end

local success, message = pcall(apple) -- DO NOT ADD '()' AFTER THE FUNCTION!!

if success then
else
end


It will continue the script and will print you the error (if you want, you can use warn() so you can see it easier)

The other way is this

local success, message = pcall(function()
print('Hey')
end)


And you can do the same with the success, and message variables it returned

0
Edited 2 years ago

https://wiki.roblox.com/index.php?title=Global_namespace/Basic_functions#pcall

pcall is used for catching errors when functions are passed. Helps with game errors etc.