local Text1 = script.Parent.TextLabel
button.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
for i = 1,45 do
local Number = 45
Number -= 1
Text1.Text = Number
wait(1)
end
debounce = false
end
end)
Is Text1 a variable? I don’t see you declaring it anywhere in that script…
I assume you are setting the debounce variable at the start of the script?
this will always make Number 44
local Text1 = script.Parent.TextLabel
local debounce = true
button.MouseButton1Click:Connect(function()
if debounce then
debounce = not debounce
for Number = 45, 1, -1 do
Text1.Text = Number
task.wait(1)
end
debounce = not debounce
end
end)
it only changes once then stops
yes, i didn’t put the whole script here. i think the problem is with the loop
Actually, it won’t. Number - 1
would, whereas Number -= 1
sets the variable Number to once less than what it was.
However you’re right as the number is being re-set to 45 each time through the loop. @micopiri6 that’s the problem, set Number to 45 before the loop.
I use that as a shortcut instead of number = number - 1
I edited my reply
and yes it will!
the variable Number was declared in the for loop so it’s value would be like this
45 - 44 - 45 - 44…
Thanks for helping, i didn’t know that i was reseting the number to 45 everytime.