I'm working on a tycoon machine, and I discovered that the part that will give money once touched does not destroy the first part it detects once touched. In other words, the first part is not destroyed, but once it is gone, the rest are destroyed. Here is the script:
local debounce = false script.Parent.Touched:connect(function(hit) if debounce == true then return end if debounce == false then debounce = true local tycoonowner = script.Parent.Parent.Parent.TycoonOwner local player = game.Players:GetChildren() for i = 1, #player do if player[i].Name == tycoonowner.Value then player[i].leaderstats.Money.Value = player[i].leaderstats.Money.Value + script.MoneyAwarded.Value hit:Destroy() end if player[i].Name ~= tycoonowner.Value then end end wait(1) debounce = false end end)
You have so many unneeded things in there. Try this:
local tycoonownerVal = script.Parent.Parent.Parent.TycoonOwner local money = script.MoneyAwarded script.Parent.Touched:connect(function(hit) hit:Destroy() local tycoonowner = game.Players:FindFirstChild(tycoonownerVal.Value) if tycoonowner then tycoonowner.leaderstats.Money.Value = tycoonowner.leaderstats.Money.Value + money.Value end end)
Tell me if this is not what you wanted.