I've seen previously in the past the uses of the pcall variations; however, some don't appear to work, and sometimes, to me, they don't work (at all).
One usage I've seen is the following:
local player = game.Players.LocalPlayer
pcall(function()
player.PlayerGui.ScreenGui.TextLabel.Text = 'String'
end)
Or, similarly, this:
local Player = script.Parent
pcall(function()
Humanoid.Health = 0 -- How is that even supposed to work..?
end)
But one of the major issues is that it masks errors:
function printWrittenIncorrectly()
printttt('Hi! :D')
end
pcall(printWrittenIncorrectly)
However, you can retrieve the data it masks by doing the following:
function printWrittenIncorrectly()
printttt('Hi! :D')
end
local Fired, Error = pcall(printWrittenIncorrectly)
if not Fired then
print(Error)
else
print('Code fired!')
end
But this is only one of the uses I'm aware of that'll work properly; but even so, you have to do that to unmask the error it hid.
Back to my question: How does pcall, xpcall, and ypcall actually work?

1 comment
What do you mean how does it work? It terminates your function rather than your script if there is an error.