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