Countdown text isn't working

Hi,

i have a problem with my countdown text.

local TimeWait = script.TimeWait
local reset = script.Reset

while wait() do
if TimeWait.Value == 0 and reset.Value == false then
TimeWait.Value = 10
reset.Value = true
elseif reset.Value == false then
TimeWait.Value = TimeWait.Value -1
print(TimeWait.Value)
wait(1)
end
end

No errors and nothing gets printed.

Thanks!

2 Likes

Try using “for i do”, here’s a tutorial for these:

how would the script looks like? im too dumb xd.

There are examples of how to use for loops. You would set the start as 10, end as 0, and increment as -1.

while true do
for i = 10,0,-1 do
wait(1)
print(i)
end
end
1 Like

You can do it without the while loop.

without the while loop it isn’t infinite.

full script? or do i need to add something? and where in my script?

because i want it with the reset value

Your second IF statement isn’t passing. You set reset.Value as True in first IF statement, script sees that it doesn’t pass first IF, tries to pass second IF but doesn’t pass too since reset.Value is True, while it requires False. Basically after first loop it never passes any IF, so it does nothing after it.

Also, I won’t recommend using wait() in a while loop. Instead of it use game:GetService(“RunService”).Stepped:Wait() for server script and game:GetService(“RunService”).Heartbeat:Wait() for local script.

can you send the full script? im not a native english speaker i cant understand very good

while wait() do
if TimeWait.Value == 0 and reset.Value == false then
TimeWait.Value = 10
reset.Value = true
elseif reset.Value == true then
TimeWait.Value = TimeWait.Value -1
print(TimeWait.Value)
if TimeWait.Value == 0 then reset.Value = false end
wait(1)
end
end

but the value is basically on true so that the countdown isnt starting. If the countdown is 0 the countdown shoudl stop because then i made the reset value. So the value needs to be true at the end

while true do
for i = 10,1,-1 do
print(i)
wait(1)
end
reset.Fire()
end

here’s the full script. i know that here it assumes that reset is an event. this is because if you try to set the value of it, it will immidiately need to get reset back to the opposite state. Assuming that you’ve bound the other scripts to a propertychanged event, that should work. but it’s inefficient.

If you change it to an event it will work better, though if you want to have an intermission like those in minigame games, you can do this:

-----------------For the minigame/round start------------
while true do
for i = 10,1,-1 do
print(i," RoundTimer")
wait(1)
end
reset.Value = true
-----------------For the intermission------------
for i = 10,1,-1 do
print(i," Intermission")
wait(1)
end
reset.Value = false
end
1 Like