Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my debounce not working properly?

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

✓ Accepted answer

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.