When should I wrap GetService inside a pcall?

Should I ever wrap GetService inside of a pcall? Does GetService(“DataStoreService”) and GetService(“MarketplaceService”) have a chance of throwing an error?


1 Like

No, neither of them have a chance of throwing an exception. The only time ServiceProvider:GetService throws an exception is if the string does not represent a valid service name, or if the argument is not a string.

However I doubt you’ll encounter any of these problems.


No, you don’t need to wrap the GetService method of game in a pcalls. What you need to wrap are something that requests an HTTP, Datastore, and even GetRankInGroup. Those examples requests some data back that is not in the server.

1 Like

Should I be using pcall with HttpService:JSONEncode? Does it actually make http requests?

No it does not make HTTP requests.

1 Like