Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Game Pass GUI not working?

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

✓ Accepted answer

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.

2 comments

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?

0

Oh. I forgot to add the line that actually prompts me to buy the Game Pass. Ty for your help!

This discussion is preserved as it was. New answers, comments, and votes are closed.