quebrado
(quebrado)
#1
Hey everyone! I would like to know how could I add a cooldown to this script I made:
Hover.MouseButton1Click:Connect(function()
if WindowVisibility.Value == false then
WindowVisibility.Value = true
print("Opened")
else
WindowVisibility.Value = false
print("Closed")
end
end)
I tried to make something like this, but then the script stops working after the first input:
local debounce = false
--click
if debounce then return end
debounce = true
--function
wait(.2)
debounce = false
1 Like
If you don’t want to script to yield you can use task.spawn with the debounce.
1 Like
KJry_s
(MalleoZephyris)
#3
- Store the
debounce
as a variable
- If the
debounce
is active then return (make sure it’s in a function then
- Set the debounce to
true
after the return
- Do whatever you want.
- Have a cooldown time and
wait
here.
- set the
debounce
as false
once more.
local db = false
-- click
if db then return end
db = true
... -- code here
task.wait(.2) -- cooldown time
db = false
4 Likes
KJry_s
(MalleoZephyris)
#4
Also if that solves it mark a reply as solution
so that this post gets archived.
quebrado
(quebrado)
#5
Yes! I was doing the cooldown stuff inside the if
statements. Thank you so much for the help!
2 Likes
KJry_s
(MalleoZephyris)
#6
Yeah that also works, it looks alike:
local db = false
if not db then
db = true
...
task.wait()
db = false
end
system
(system)
Closed
#7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.