Countdown is Only Visible For Half of a Second

Good morning/afternoon/evening!

So I’m making a round based game with an intermission. I’m making the intermission count down from 20 to 1. When it gets to one, I change the status to “Choosing Map…” for 2 seconds, then make it say “(name of map goes here) has been chosen!”. The map-related statements work just fine, but the intermission countdown is only visible for a fraction of a second, and because of this, I can’t even see if it actually counts down or not when I’m testing the game. Here’s the code:

for i = 20, 1, -1 do
		Status.Value = "Intermission ("..i..")"
		if Status.Value == "Intermission (1)" then
			Status.Value = "Choosing map..."
		end	
	end

I tried adding a wait(20) after this line:

Status.Value = "Intermission ("..i..")"

The intermission was visible for the full 20 seconds, but it never counted down. Any ideas as to what may be causing the issue? I’m a beginner at scripting, so I’m learning from my mistakes day by day. Thanks for reading! :slight_smile:

Add a wait(1) (30 charssssssss)

2 Likes

If you don’t have a wait(1) it will countdown instantly

1 Like

You should be putting the wait call as the last statement.

for i = 20, 0, -1 do
    Status.Value = string.format("Intermission (%d)", i)
    wait(1)
end

Status.Value = "Choosing map..."

You don’t need to set the text to choosing map in the loop—just outside of it. Once the loop breaks it will continue to the code under.

I also used string.format instead which makes this cleaner.

3 Likes

Instead of “if Status.Value == “Intermission (1)” then” why not just put “if i == 1 then”

1 Like

Thanks for the tip! I’m guessing that this makes the code easier to read.

1 Like