Hi all If a pcall for :UserOwnsGamePassAsync fails should I loop it and if so, does it have a maximum amount of requests it can handle.
I don’t ever recommend polling any web calls unless you have to. If UserOwnsGamePassAsync fails, check it again during another critical point in gameplay if it hasn’t recently been checked: opening a shop, purchasing a product, after a round finishes or during some other notable point in the session where a player may need that pass active.
All web calls, internal or not, have an imposed maximum but it doesn’t usually get documented. I don’t know what this number is though but if it fails you can expect to pile errors for multiple users and exhaust your call budget.
Im not to sure if your always trying to see if a player owns a gamepass but i dont recommend looping it.
Instead of looping it, create a function that has the code if a player did own the gamepass then connect that function to a successful purchase or whatever.
What if the purchase is needed from the start of the game, it affects the way the game is played from the start. Would i just kick them?
No, just hold them in limbo and perform the request every minute or so, the player can decide to stay (if they are patient enough) or leave at their own discretion.
You can retry the purchase maybe 3 times if it’s a critical purchase needed at the start but at that point you should also be concerned about what exactly the error is and if retrying will have any bearing. If it’s an endpoint outage, you aren’t going to get a successful call later.
Marketplace endpoints usually have good uptime but if the function is failing because the endpoint is down you probably don’t want people getting into your game, that could be representative of a critical issue and other features may also not be working as expected.
All of the previous replies to this thread completely gloss over the fact that UserOwnsGamePassAsync caches the result. Once you call it the first time, that result is stored, and subsequent calls won’t even do anything. Calling it more than once is completely unnecessary.
So don’t ever call it until you’re sure the user has decided to buy it or not. If you do call it at the start of the game, then make sure to offer in-game purchase screens via MarketplaceService:PromptGamePassPurchase
so that you can use the PromptGamePassPurchaseFinished
event to detect when someone just bought the gamepass.
This is the cause for the infamous “it doesn’t work until you rejoin the game” gamepass behavior. This is also why games with gamepasses tend to offer purchase screens in-game to buy them, so that you don’t have to buy them on the website and then rejoin.