How to prompt gamepass and check if it was bought

Im currently trying to add a gamepass to my game and make it automatically check if the player has bought it after the gamepass prompt closed.

Im not good in explaining but I’ll try;

  • Gamepass prompt shows
  • Player buys it
  • Game checks automatically if player bought it or not
  • If bought, give player reward (I will obviously code this part myself)

I dont have any idea how I can code that, this is what I’ve got right now in a local script:

script.Parent.MouseButton1Click:Connect(function()
	game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 26733577)
	-- How do I check if player bought gamepass after the prompt?
end)

Try:

game.MarketplaceService:UserOwnsGamePassAsync(UserId, GamePassId)

2 Likes

Connect a function to MarketplaceService.PromptGamePassPurchaseFinished.

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, wasPurchased)
      if gamePassId == myGamePassId and wasPurchased then
            print("The gamepass was prompt was completed and the gamepass purchased")
      end
end)

(Note: This is done on the server)

3 Likes

Not really this, this checks if the user owns it at a given time, the event I sent is trigerred whenever the prompt is finished, automatically.

1 Like

You’re correct. I missread what the sentence said.