How intensive is pcall()?

Hello,
I’m aware that using pcall() for this purpose is probably uncommon, most of the time I see it in usage with DataStores.
I’m creating firearms for other people to use, my firearms use roblox animations. I’m allowing other players to choose whether or not they want certain poses to be usable, which is determined by if the animation is correctly loaded (if there is a valid animation ID in the animation object). For this case, I am using pcall() for each pose.
Eg. if pcall() for the Saluting animations returns as a success, that means that the characters can use the Saluting pose. If returns false, then they cannot.
I do have a lot of poses, how intensive would pcall() be? Additionally, would there be any better alternative to this? I feel like I am misusing pcall()…

Thanks! (LMK if you need any more context)

From my knowledge - pcall() is the equivalent of try/catch statements in other languages, so I believe pcall() would only be as resource intensive as you make it (i.e spawning 1000 parts would make it heavy, whilst spawning a single part would be light)

1 Like

I’ve never used pcall() before, this is my first usecase; I’m planning on using pcalls() ten times. That’s not intensive at all, is it?

Again - depends on the usage, although I don’t see why 10 pcalls would be necessary

Usually, errors happen in a script, the script is stopped at that line. When you use a pcall, the script will resume even if there is an error. If I am not wrong It’s used mostly when you are unaware whether the code will run successfully or fail

Check this post out for detailed info : https://devforum.roblox.com/t/pcalls-when-and-how-to-use-them/393687

1 Like