Hey, I was wondering about adding a debounce script to my script. The script is basically when a "player" clicks a part they get +1 Money But... there's something about the denounce that doesn't work I get no errors in the console but when I click it doesn't work.
Thanks if someone knows how to do this :D
local debounce = false
local Button = script.Parent.ClickDetector
Button.MouseClick:Connect(function()
if not debounce then
debounce = true
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local PlayerMoney = player.leaderstats.Money
PlayerMoney.Value = PlayerMoney.Value +1
end)
wait(5) -- Cool Down Time
debounce = false
end
end)

1 comment
You had to put the debounce inside the event.