PromptGamePassPurchaseFinished

Hello all,

I’m having an issue with PromptGamePassPurchaseFinished. It is working perfectly fine in Studio/Solo Play mode, but, as soon as I do it on a server it doesn’t work. The purchase is definitely made as, when I rejoin, I have the game passes, but, it doesn’t trigger the “PromptGamePassPurchaseFinished” code.

In Studio, it does do the “PromptGamePassPurchaseFinished” code. The code is written in a server script.

local function gamepassPurchaseFinished(player, gpid, wasPurchased)

if wasPurchased == true then

if gpid == 5940972 then

print("Do certain things for this Game Pass")

end

if gpid == 5940963 then

print("Do certain things for this Game Pass")

end

if gpid == 5940956 then

print("Do certain things for this Game Pass")

end

end

end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)

Any help or information about this would be appreciated.

Thanks,
Ryan.

Kindly make your code formatted as seen below by adding 4 spaces on each line or by pressing Ctrl + Shift + C

Please use elseif statments instead of various if statements as shown below :slight_smile:

local function gamepassPurchaseFinished(player, gpid, wasPurchased)
 if wasPurchased == true then
  if gpid == 5940972 then
   print(“Do certain things for this Game Pass”)
  elseif gpid == 5940963 then
   print(“Do certain things for this Game Pass”)
  elseif gpid == 5940956 then
   print(“Do certain things for this Game Pass”)
  end
 end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)

As for what the OP is requesting, I believe there is a bug with MarketplaceService.PromptGamePassPurchaseFinished at the moment.

2 Likes

Should I disable game passes for now then or just leave it as is as my code for checking whether the user has the game pass or not is working?

You may disable gamepasses because it could be causing a lot of issues in your game and you may not because I believe this bug will be fixed very soon.

Nice code dude. :smile: :+1:

Anyway, I’d also like to add that because you’re using gamepasses, if you want to do something like kill the player if they don’t buy the gamepass, make sure to use MarketPlaceService’s UserOwnsGamepassAsync as it’ll check if they already own the gamepass.

Now lets pretend you want to make it so if they don’t buy it or own it they die.

If you don’t use the gamepass Async, the player will die since wasPurchased == false as you can’t buy a gamepass you already own. If you do use it, this won’t happen.

Anyway, yeah that’s about it have a good day. :smile:

2 Likes

For now, I have added the UserOwnsGamepassAsync coding to check and see if the user has the Game Pass when they open the GUI. This will save them from having to rejoin to see they have the game pass.

1 Like

That works too :slight_smile: