How to check if someone bought a gamepass off the website ingame

Right now I’m using MarketplaceService:PlayerOwnsAsset(player, assetid)
Is there anything that picks up on if the person buys the asset off the game page? I’d like to update the player’s inventory without requiring them to leave and come back

5 Likes

Interestingly, I was just looking into this a few hours ago, and here you go:
MarketplaceService:UserOwnsGamepassAsync(userId, gamepassId)

That shouldn’t cache as far as I’m aware. I don’t think there’s any event-based solution though that I’m aware of.

7 Likes

Just as a design suggestion to get around the lack of signals, maybe add a button somewhere where the user can refresh their in-game gamepass-ownership states?

Not sure if it’s worth the effort, though. I’d only consider it worth it if your UI is bad enough that the player can’t easily get to the gamepass shop in-game (or just is not designed to sell gamepasses).

Doesn’t work for some reason. Even if I leave and rejoin. Isn’t this that new feature they were testing but backpedaled on?

It worked for me. I had to update my gamepass IDs to the new IDs that are on the pages though.

For example, this line of code works to check if I own a “Monorail” gamepass for my game:
print(game:GetService("MarketplaceService"):UserOwnsGamePassAsync(308165, 3638223))

1 Like

How do you get the correct ID?

Just go to the webpage that the gamepass is on (like my monorail one above) and grab the number in the URL. Gamepasses have their own dedicated IDs now. Before they were just in the big collection of assets like everything else.

Still doesn’t work for some reason, even with the updated ID :\

EDIT: I’m an idiot and forgot to do game.MarketplaceService since I just copied the line you posted

ANOTHER EDIT: Nope, apparently I had it as a variable anyway. UserOwnsGamePassAsync is apparently not a member of MarketplaceService

AND ONE MORE: The P is capitalized.

Does this work on test servers in Studio? Because it seems to not work still, with no errors.
I’m trying to test this gamepass: Cyber Ninja Pack - Roblox

Yup it worked for me. It returned false, and then I bought it, and it returned true.

In a local test server, right?

print(MarketplaceService:UserOwnsGamePassAsync(player.UserId, 4308951))

I do this (MarketplaceService is already a variable for game:GetService(“MarketplaceService”))
false
I buy the pass and run the code again
false

:S

This on the other hand works right on the spot:

MarketplaceService:PlayerOwnsAsset(player, 4308951)

4 Likes