Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to check if someone bough the gamepass?

Asked by 5 years ago

So I know how to prompt the purchase, and I know how to check if someone has it. But how do I check if someone bought it after the prompt purchase?

2 answers

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
5 years ago

You will have to check whether the gamepass /product own is true so you could do something like this

1local hasPass = false
2 
3    -- Check if the player already owns the game pass
4    local success, message = pcall(function()
5        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
6    end)
Ad
Log in to vote
0
Answered by 5 years ago
1local market = game:GetService("MarketplaceService")
2local plr = game:GetService("Players").LocalPlayer
3local gamepass = 0 --change to your gamepass ID
4 
5if market:PlayerOwnsAssest(plr, gamepass) then
6    --put in the script where the player owns it
7else
8    game:GetService("MarketplaceService"):PromptPurchase(game.Players.LocalPlayer, gamepass)
9end

Answer this question