Hello, ScriptingHelpers!
Sometimes, my tycoon collector would generate too much money from money bricks.
The thing is that sometimes the amount of generated money (shown on the GUI where players collect money) would jump from 10k, 20k to 1M, which is actually something like 2000000142.
I've been told that debounce could be a fix, but I'm not sure how to add debounce to my script.
SCRIPT WHICH CONVERTS DROPPED BRICKS TO MONEY:
script.Parent.Essentials.Collector.Touched:connect(function(hit)
if hit:FindFirstChild("Cash") then
script.Parent.Cash.Value = script.Parent.Cash.Value + hit.Cash.Value
Instance.new("Sparkles",hit).Color=Color3.new(math.random(1,255)/255,math.random(1,255)/255,math.random(1,255)/255)
game.Debris:AddItem(hit,0.1)
end
end)

2 comments
Have you tried communism?
Joking asside, where is the script that handles how money is displayed? A debounce will surely make things better, but it might not be the only problem.