Countdown Gui seems glitched but worked just a little while ago

I was working on a countdown GUI (via RemoteEvents) that fires to all players who are not marked AFK (this has already been handled and it works perfectly). The issue I am encountering is that when I use the for i = 3, 1, -1 do loop it prints “1” each time, rather than going from 3, to 2, to 1. So the countdown GUI itself goes from 1 to “GO!” and that’s it; it completely skips 3 & 2.

Here is a snippet of the code in ServerScriptService:

    for i, player in ipairs(playingPlayers) do
		game.ReplicatedStorage.WaitCountdown:FireClient(player, "Prepare")
	end
	wait(1)
	for i = 3, 1, -1 do
		for i, player in ipairs(playingPlayers) do
			print(i) -- I used this to identify the issue
			game.ReplicatedStorage.WaitCountdown:FireClient(player, i)
		end
		wait(1)
	end
-- I had some other code here that handled other stuff, it worked so I didn't include it here

My code in the LocalScript that controls the Countdown GUI gets a little nitty-gritty because of Tweening, so I’ll just describe what each thing does:

  • “Prepare”: Opens up the GUI with a Tween animation.
  • 3: Tweens in the number 3.
  • 2: Tweens in the number 2 and tweens out the number 3.
  • 1: Tweens in the number 1 and tweens out the number 2. Then, after a little time, it tweens out the number 1 and tweens in the word “GO!” and after a while it closes up the GUI. If you want to see the issue in action join Frenzy Sprint.

All I see in the output section is “1”, 3 different times. I’ve tried restructuring the code many times but no success has come out, mostly because I don’t even understand what the issue is. I would really appreciate it if someone could help me make sense of what’s going on. Thanks in advance everyone!

You are overwriting the ‘i’ variable.
Player 2 will see ‘2’ three times, player 3 will see ‘3’ three times, and player 4 will probably just have an error. If you are not going to use a variable, a common practice is to replace it with an underscore.

for i = 3, 1, -1 do
    for _, player
1 Like