Gamepass button error

So I have a tycoon, and I have a gamepass button for 2x money:

image

When you touch it, on screen should appear gamepass, but it doesn’t, here is what appears:

image

But, I puted gamepass to 200 rbx:

But still it isn’t working…

Btw here is the script:

local Settings = require(script.Parent.Settings)
local Tycoon = script.Parent.Tycoons:GetChildren()[1]
script.Parent = game.ServerScriptService
local DevProducts = {}
local MarketplaceService = game:GetService('MarketplaceService')

for i,v in pairs(Tycoon:WaitForChild('Buttons'):GetChildren()) do
	if v:FindFirstChild('DevProduct') then
		if v.DevProduct.Value > 0 then
			DevProducts[v.DevProduct.Value] = v -- the button
		end
	end
end

MarketplaceService.ProcessReceipt = function(receiptInfo)
	for i,plr in pairs(game.Players:GetPlayers()) do
		if plr.userId == receiptInfo.PlayerId then
			if DevProducts[receiptInfo.ProductId] then
				local obj = DevProducts[receiptInfo.ProductId]
				local PlrT = game.ServerStorage.PlayerMoney:WaitForChild(plr.Name).OwnsTycoon
				if PlrT.Value ~= nil then
					--if PlrT.Value.PurchasedObjects:FindFirstChild(obj.Object.Value) == false then
						local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
						Create({[1] = 0,[2] = obj,[3] = PlayerStats}, PlrT.Value.BuyObject)
					--end
				end
			end
		end
	end
end

function Create(tab, prnt)
	local x = Instance.new('Model')
	Instance.new('NumberValue',x).Value = tab[1]
	x.Value.Name = "Cost"
	Instance.new('ObjectValue',x).Value = tab[2]
	x.Value.Name = "Button"
	local Obj = Instance.new('ObjectValue',x)
	Obj.Name = "Stats"
	Obj.Value = tab[3]
	x.Parent = prnt
end

If you know what is problem, I would appreciate your help.

This probably has something to do with how you prompt the purchase window.
But you didn’t send that part of the script.

I am a bit confused. You said that you made and put on sale a gamepass but in your code your dealing with DevProducts?

My guess is that you don’t know what the difference between a DevProduct is and what a gamepass is causing you to create a gamepass rather then a DevProduct (a gamepass is more of a one purchase only item but DevProducts are where you can buy them more then once.)

Although looking at the code there is no where you prompt the purchase like what @bnxDJ said. Mind sending this code and the “gamepass” ID?

1 Like

Oh, I see now, but then how I can make it to be gamepass and not devproduct?

You would use the PromptGamePassPurcase (MarketplaceService | Roblox Creator Documentation) to prompt a purchase and I think you should be able to use either PromptGamePassPurchaseFinished event to detect when the user purchases the gamepass or you could manually check with the method UserOwnsGamePassAsync

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.