Ok, so I'm trying to add a cooldown to my gui that when you press k the gui opens with a smooth animation and you have to wait until the cool down that is 6 seconds long but it, went wrong, and then, something went wrong in the output and you still can spam the gui to open.
The code:
local Plr = game.Players.LocalPlayer
local mainframe = script.Parent
local debounce = false
Plr:GetMouse().KeyDown:Connect(function(K)
if not debounce then
debounce = true
end
if K == "k" then
local object = script.Parent
object.Position = UDim2.new(0.183, 0,0.999, 0)
wait(0.1)
object:TweenPosition(UDim2.new(0.183, 0,0.875, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint)
wait(6)
debounce = false
end
end)

3 comments
Ok, I'm gonna try it.
Thank you so much!
No problem.