Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my debounce not working properly?

Asked by 3 years ago
local seconds = 180
local minutes = math.floor(seconds/60)
local remainder = seconds % 60
local clock = script.Parent.Parent.TextLabel
local debounce = false

script.Parent.MouseButton1Click:Connect(function()
if not debounce then
debounce = false
for i = 1, remainder do
wait(1)
if minutes > 9 then
if remainder - i < 10 then
clock.Text = minutes..":0"..remainder - i
else
clock.Text = minutes..":"..remainder - i
end
else
if remainder - i < 10 then
clock.Text = "0"..minutes..":0"..remainder - i
else
clock.Text = "0"..minutes..":"..remainder - i
end
end
end
for i = 1, minutes do
for i = 1, 60 do
wait(1)
if minutes > 9 then
if 60 - i < 10 then
clock.Text = minutes..":".."0"..(60-i)
else
clock.Text = minutes..":"..(60-i)
end
else
if 60 - i < 10 then
clock.Text = "0"..minutes..":0"..(60-i)
else
clock.Text = "0"..minutes..":"..(60-i)
end
end
end
minutes = minutes - 1
end
wait(180)
debounce = false
end
end)

I did alot of GUI scripts with debounce but this script is the longest. I just cant find out why the debounce doesnt work. Please help thank you.

The output says that line 4 has an error. But without the debounce this script works normally like a timer.

2 answers

Log in to vote
1
Answered by 3 years ago

See it's a simple mistake, don't worry I also make it all the time.

The error is found in line 9

you put:

debounce = false

after that it's self explanatory

Ad
Log in to vote
0
Answered by 3 years ago

You put if not debounce then debounce = false It should be true.

Answer this question