I am trying to make a shop GUI with image buttons that, when clicked, will prompt the person to buy the game pass. Here is the script, it is basically the same as what I found on the wiki, but I added a function onClick(). Is there more to it then that that I am missing?
local passId = 296166917 --change this to your GamePass Id
local marketplaceService = game:GetService("MarketplaceService")
function onClick()
marketplaceService.PromptPurchaseFinished:connect(function(player,assetId,isPurchased)
if isPurchased then --if the player did pay
if assetId == passId then --if what they bought is the pass
print(player.Name .. " bought the pass (" .. passId .. ")")
end
end
end)
end

2 comments
Huh. For some reason it isnt prompting me to purchase the Game Pass. It should appear telling me I already own it as I am the creator of the pass. Am I missing something else?
Oh. I forgot to add the line that actually prompts me to buy the Game Pass. Ty for your help!