When im testing a gamepass In studio and click on buy it says purchase succeeded but if i prompt the purchase again it tells me to buy it again how can I fix this? (it also prints error when purchase succeeded )
Thanks!
Marketplace:PromptGamePassPurchase(player, GamepassId)
Marketplace.PromptGamePassPurchaseFinished:Connect(function()
if Marketplace:UserOwnsGamePassAsync(player.UserId, GamepassId) then
print("ownspass")
else
print("error")
end
end)
obviously test purchases dont actually give gamepasses; if you are the creator of the gamepass you can’t even buy it in the first place
tldr;use a value to check if it gets bought/owned correctly if you have that approach
The thing is that purchases in Studio are simulated. It should be showing that for the current session, OP does own the game pass and PromptGamePassPurchaseFinished should be firing.
I think the primary issue is that they are also coupling it with UserOwnsGamePassAsync which does cache or may not be returning the right result. Try removing UserOwnsGamePassAsync and running the test again. You won’t need it anyway since you can use the parameters of UserOwnsGamePassAsync (which you don’t) to check if a purchase was successful. @Gatuno7000
Marketplace.PromptGamePassPurchaseFinished:Connect(function (player, passId, wasPurchased)
if wasPurchased then
print("ownspass")
else
print("cancelled")
end
end)
Marketplace:PromptGamePassPurchase(player, GamepassId)
Typically you shouldn’t be able to repurchase the game pass again in that specific test session, but I would imagine this is just the result of it being a test purchase and nothing else.
It’s completely normal. You could also request for test purchase caching for the current test session if that isn’t a feature already to make it easier for yourself when working with game passes in Studio.
It would be good practice for you anyway to manually cache somewhere that the player owns the game pass after purchase rather then rely on frequent uses of UserOwnsGamePassAsync. I personally intend to do this with attributes when they’re finally released (when will they be…).