Hello, I am making a tycoon and have some weird complication, or perhaps it is a problem in my scripts. In my tycoon there are buttons that are dev products, when you step on them, they properly work, prompt a purchase, complete the purchase, and the assigned dropper or object appears. Apart from this, I created a gui shop to add on to the tycoon, which uses dev products as well. That's where everything broke. If I play the tycoon, I can only either purchase the cash/walkspeed/health boosts, or the dev objects in the tycoon, it depends which one I choose to do every play. What happens if I purchase cash, I then try to purchase the dev product objects, the transaction properly goes through, but the object doesn't appear. I've tried searching for the problem, but could not find it, or make the slightest sense of what it could be. However, when I delete the the main script of the shop gui to make sure it works and prompt the purchases which is in the serverscriptservices, the dev product objects work perfectly fine. Here are some scripts related to the dev products.
The local script inside the Shop GUI:
for i,v in pairs(script.Parent.Buttons:GetChildren()) do if v:isA("TextButton") then v.MouseButton1Click:connect(function() pcall(function() if v:FindFirstChild("Pass") then game.MarketplaceService:PromptPurchase(game.Players.LocalPlayer,tonumber(v.Name)) else game.MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,tonumber(v.Name)) end end) end) end end
The main script of the dev product shop gui (or the dev product handler) in servicescriptservice:
local MarketplaceService = game:GetService("MarketplaceService") function getPlayerFromId(id) for i,v in pairs(game.Players:GetChildren()) do if v.userId == id then return v end end return nil end MarketplaceService.ProcessReceipt = function(receiptInfo) local productId = receiptInfo.ProductId local playerId = receiptInfo.PlayerId local player = getPlayerFromId(playerId) local productName if productId == 51151679 then productName = "$25,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 25000 end elseif productId == 51151684 then productName = "$50,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 50000 end elseif productId == 51151691 then productName = "$75,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 75000 end elseif productId == 51151723 then productName = "$100,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 100000 end elseif productId == 51151734 then productName = "$250,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 250000 end elseif productId == 51151739 then productName = "$500,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 500000 end elseif productId == 51151758 then productName = "$750,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 750000 end elseif productId == 51151788 then productName = "$1,000,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 1000000 end elseif productId == 51151814 then productName = "$5,000,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 5000000 end elseif productId == 51151827 then productName = "$10,000,000" local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) if cashmoney then cashmoney.Value = cashmoney.Value + 10000000 end elseif productId == 51152591 then productName = "10 Walkspeed" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then human.WalkSpeed = human.WalkSpeed + 10 end end elseif productId == 51153173 then productName = "30 Walkspeed" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then human.WalkSpeed = human.WalkSpeed + 30 end end elseif productId == 51153297 then productName = "50 Health" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then human.MaxHealth = human.MaxHealth + 50 human.Health = human.Health + 50 end end elseif productId == 51153323 then productName = "100 Health" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then human.MaxHealth = human.MaxHealth + 100 human.Health = human.Health + 100 end end elseif productId == 50163423 then productName = "Hex Spitter" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then print("Check Complete") end end elseif productId == 50163462 then productName = "Rapid Launch Blaster" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then print("Check Complete") end end elseif productId == 51071904 then productName = "Super Ultra Gatling Laser Gun" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then print("Check Complete") end end elseif productId == 50652188 then productName = "Super Ultra Mega Electric Dropper" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then print("Check Complete") end end elseif productId == 51071996 then productName = "Super Ultraviolet Insta Kill Blaster" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then print("Check Complete") end end elseif productId == 49472555 then productName = "Ultra Mega Dropper" local char = player.Character if char then local human = char:FindFirstChild("Humanoid") if human then print("Check Complete") end end end game.BadgeService:AwardBadge(0) local message = Instance.new("Hint",workspace) message.Text = player.Name.." purchased "..productName.."!" coroutine.resume(coroutine.create(function() wait(2) message:destroy() end)) return Enum.ProductPurchaseDecision.PurchaseGranted end
The dev product handler inside the actual tycoon model:
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 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 local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name) Create({[1] = 0,[2] = obj,[3] = PlayerStats}, PlrT.Value.BuyObject) 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
Hopefully one of you helpers can give me a guide or tell me what I'm doing wrong, thanks.