My cash collects automatically collect cash and put the value on the leaderboard. But sometimes the collecters randomly collects twice as more than the original value of the dropper cube, for example, the collectors collect $4 instead of $2.
Here is the code:
local Money = script.Parent.Amount
local Debris = game:GetService('Debris')
for i,v in pairs(script.Parent.Parent:GetChildren()) do
if v.Name == "CollectorPart" then
v.Touched:connect(function(Part)
if Part:FindFirstChild('Cash') then
Money.Value = Money.Value + Part.Cash.Value
Debris:AddItem(Part,0.2)
--print(Money.Value)
end
end)
end
end
The Money is an int value where every 0.11 sec it sets to zero; here is the code:
while true do
wait(0.11)
script.Parent.Value = 0
end
Thanks for the Help!

2 comments
Is this from a Udemy lesson?
no