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

Game Pass GUI not working?

Asked by 8 years ago

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

1 answer

Log in to vote
0
Answered by 8 years ago

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.

0
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? Malefactus 55 — 8y
0
Oh. I forgot to add the line that actually prompts me to buy the Game Pass. Ty for your help! Malefactus 55 — 8y
Ad

Answer this question