I made a save button to save your data when you click on it but I want it to have a cooldown since there is a limit in datastores.
I'm trying to make it so when you click on the save button it will have a 60 second cooldown and you will have to wait 60 seconds until you can save again.
Here's what I have so far..
local debounces = false
saveiconbutton.MouseButton1Click:connect(function()
if debounces == false then
local debounces = true
savinglabel.Text = "Saving.."
savinglabel:TweenSize(UDim2.new(0, 200, 0, 50), "Out", "Quad", 0.5) -- this will pop up a textlabel telling you that your data is saving
ds1:SetAsync(plr.UserId, moneyStats.Value)
wait(5)
savinglabel.Text = "Saving Success!"
wait(2)
savinglabel:TweenSize(UDim2.new(0, 0, 0, 0), "In", "Quad", 0.5)
else
for v = 60, 0, -1 do
wait(1)
if v > 1 then
savinglabel.Text = "You can save in "..v.."seconds."--this will tell the play how much longer you have to wait to save again
break
elseif v < 1 then-- if the 60 seconds is up then it will make it so you can click the button again
local debounces = false
end
end
end
end)
But instead of just waiting 60 seconds, I can spam click the button and it would save each time.. Any idea how to fix it?
