UserOwnsGamePassAsync On Server or Client

Should i use UserOwnsGamePassAsync on the server or client to check whether a player has a gamepass?

Both.
Example:
Say I have a GUI that shows whether or not I bought it or a menu only for people who bought it.
You would check if they have the gamepass (on server) when they choose something from the menu and you can show the gui or bought icon based on whether or not client says so. That way youre not constantly pestering server and you also have security.

5 Likes

Does it update when you buy a gamepass in the middle of the game? or do u need to rejoin for it to work

Look on the wiki for related functions. But i think it caches every 10 seconds until they buy it then it caches entire server

so basically yes, it just takes some time

Also shouldnt this be used https://www.robloxdev.com/api-reference/function/GamePassService/PlayerHasPass
none of them are deprecated so idrk

yeah, ik i recently changed to this

No.

so

Does it update when you buy a gamepass in the middle of the game? or do u need to rejoin for it to work

UserOwnsGamePassAsync does.

2 Likes

ok thanks

kk thx for clarification. idk y they dont deprecate it

btw, you can’t use UserOwnsGamePassAsync on other players but the LocalPlayer, this is also true for BadgeService.

The issue is, if I use it on the GUI, there is a noticeable pause before the GUI updates. This is because it’s async.

How should I fix this? Should I cache the results somewhere?

You could always cache it locally by getting the result of the check beforehand (putting it in the clients save data and sending data to client on join) (dont forget to ask when the gui is refreshed anyways in case they buy it outside of the game). When they buy the gamepass you would use remote functions to make sure they actually bought it successfully. At that point, no further checks are required because they own the gamepass now.