What's the difference between UserOwnsGamePassAsync and PlayerHasPass?

So there’s two main ways to check if someone owns a gamepass:

  1. https://wiki.roblox.com/index.php?title=API:Class/GamePassService/PlayerHasPass
  2. https://wiki.roblox.com/index.php?title=API:Class/MarketplaceService/UserOwnsGamePassAsync

What’s the key difference between the two functions, and which one would you recommend using?

This thread should explain everything:

It explains that you should be using UserOwnsGamePassAsync over PlayerOwnsAsset, but I can’t find anything about GamePassService:PlayerHasPass

1 Like

Right you are - the only noticeable difference I could find on the wiki is that PlayerHasPass will cache its result, whereas UserOwnsGamePassAsync will not

So you’ll want to use the latter

5 Likes

UserOwnsGamePassAsync is newer than PlayerHasPass, but does the same thing. The only difference is that it doesn’t cache, as @ForyxeV said.

However, if you ever find two functions that serve the same exact purpose, always assume the older one is going to be deprecated. There’s never a need to have two functions serving the same purpose, and whenever they make a new one they make it for a reason.

Therefore, assume PlayerHasPass is a legacy function and will be officially deprecated soon. Use UserOwnsGamePassAsync.

3 Likes

Always use UserOwnsGamePassAsync, not only because of PlayerHasPass being depreciated, but because if someone joins your game, then buys a game pass, because PlayerHasPass caches it will keep telling you the player doesnt own the pass until that player joins a new server. This tends to make said player rather unhappy.

6 Likes

Wiki doesn’t mark PlayerHasPass as being deprecated actually…but it definitely should. In fact, the whole GamePassService should be deprecated, since it only has that one method.

Is it marked as deprecated within the actual API?

2 Likes

It will spam warnings if I use PlayerHasPass with a gamepasses old AssetId, but interestingly it works just fine if I use the new GamepassId in it. I had initially assumed it was depreciated and the wiki just hadn’t been updated, but maybe not. Still no idea why anyone would ever need to use the old method apart from for compatibility reasons though.

1 Like

When in doubt, pick the one that doesn’t cache. Always.

Thanks for all your responses - I’ll use the latter then