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
Well, function onClick()
has no way to be fired. In order to fix this, you can just add something saying if the parent is clicked, this runs:
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 script.Parent.MouseButton1Click:connect(onClick)
If this isn't what you meant, please comment so I can see what you mean.