for l,d in pairs((Tycoon:WaitForChild("\066\117\116\116\111\110\115")):GetChildren())do if d:FindFirstChild("\071\097\109\101\112\097\115\115")then if d.Gamepass.Value>0 then GamePasses[d.Gamepass.Value]=d end end end MarketplaceService.ProcessReceipt=function(l)for d,Z in pairs(game.Players:GetPlayers())do if Z.userId==l.PlayerId then if DevProducts[l.ProductId]then for d,z in pairs((script.Parent.Tycoons[Z.team.name]:WaitForChild("\066\117\116\116\111\110\115")):GetChildren())do if z:FindFirstChild("\068\101\118\080\114\111\100\117\099\116")then if z.DevProduct.Value==l.ProductId then local l=(game.ServerStorage.PlayerMoney:WaitForChild(Z.Name)).OwnsTycoon if l.Value~=nil then local d=game.ServerStorage.PlayerMoney:FindFirstChild(Z.Name)Create({[1]=0;[2]=z,[3]=d},l.Value.BuyObject)end break end end end end end end end local function l(l,d,Z)if Z then for Z,z in pairs(game.Players:GetPlayers())do if z.userId==l.userId then if GamePasses[d]then for l,Z in pairs((script.Parent.Tycoons[z.team.name]:WaitForChild("\066\117\116\116\111\110\115")):GetChildren())do if Z:FindFirstChild("\071\097\109\101\112\097\115\115")then if Z.Gamepass.Value==d then local l=(game.ServerStorage.PlayerMoney:WaitForChild(z.Name)).OwnsTycoon if l.Value~=nil then local d=game.ServerStorage.PlayerMoney:FindFirstChild(z.Name)Create({[1]=0,[2]=Z,[3]=d},l.Value.BuyObject)end break end end end end end end end end MarketplaceService.PromptGamePassPurchaseFinished:Connect(l)function Create(l,d)local Z=Instance.new("\077\111\100\101\108");(Instance.new("\078\117\109\098\101\114\086\097\108\117\101",Z)).Value=l[1]Z.Value.Name="\067\111\115\116";(Instance.new("\079\098\106\101\099\116\086\097\108\117\101",Z)).Value=l[2]Z.Value.Name="\066\117\116\116\111\110"local z=Instance.new("\079\098\106\101\099\116\086\097\108\117\101",Z)z.Name="\083\116\097\116\115"z.Value=l[3]Z.Parent=d end

for i,v in pairs(Tycoon:WaitForChild('Buttons'):GetChildren()) do
	if v:FindFirstChild('Gamepass') then
		if v.Gamepass.Value > 0 then
			GamePasses[v.Gamepass.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
				for p,b in pairs(script.Parent.Tycoons[plr.team.name]:WaitForChild('Buttons'):GetChildren()) do
					if b:FindFirstChild('DevProduct') then
						if b.DevProduct.Value == receiptInfo.ProductId then
							local PlrT = game.ServerStorage.PlayerMoney:WaitForChild(plr.Name).OwnsTycoon
							if PlrT.Value ~= nil then
								local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
								Create({[1] = 0,[2] = b,[3] = PlayerStats}, PlrT.Value.BuyObject)
							end
                            break
						end
					end
				end
			end
		end
	end
end

local function gamepassPurchaseFinished(player,gamepass,bought)
	if bought then
		for i,plr in pairs(game.Players:GetPlayers()) do
			if plr.userId == player.userId then
				if GamePasses[gamepass] then
					for p,b in pairs(script.Parent.Tycoons[plr.team.name]:WaitForChild('Buttons'):GetChildren()) do
						if b:FindFirstChild('Gamepass') then
							if b.Gamepass.Value == gamepass then
								local PlrT = game.ServerStorage.PlayerMoney:WaitForChild(plr.Name).OwnsTycoon
								if PlrT.Value ~= nil then
									local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
									Create({[1] = 0,[2] = b, [3] = PlayerStats}, PlrT.Value.BuyObject)
								end
                            	break
							end
						end
					end
				end
			end
		end
	end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)

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
