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 4 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
4 years ago

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

local hasPass = false

    -- Check if the player already owns the game pass
    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
    end)
Ad
Log in to vote
0
Answered by 4 years ago
local market = game:GetService("MarketplaceService")
local plr = game:GetService("Players").LocalPlayer
local gamepass = 0 --change to your gamepass ID

if market:PlayerOwnsAssest(plr, gamepass) then 
    --put in the script where the player owns it
else
    game:GetService("MarketplaceService"):PromptPurchase(game.Players.LocalPlayer, gamepass)
end 

Answer this question