I get how pcall works, but I don’t get when I should use it.
✓ ANSWER ACCEPTED
When should I use pcall?
2 answers
✓ Accepted answer
Use PCalls to handle things that could possibly error, such as datastores or Http requests, or if you're finding code doesn't work, you could do something like:
local success, err = ypcall(function()
ppppppppppprint("i error!")
end)
if not success then
print("Oops! I errored: " .. err)
else
print("I succeeded!")
end
This is a good tool for code errors, it is a good ally of a function if you want to keep track of what went wrong, you can use pcalls to keep track of your code carefully, putting one at each important step.
2 comments
0
Thanks
0
It slows everything down so no don't do it often.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thanks