Why does my script skip a line and how do I fix it?

So I ran into a problem where my script skips the countdown part in the for loop for some reason.
And what could be the solution to fix this issue?


local Status = game.ReplicatedStorage.Status
local Tiles = game.Workspace.Tiles:GetChildren()
local lobbySpawn = game.Workspace.LobbySpawn

while true do
	
	for i = 5, 0, -1 do
		Status.Value = "Intermission: "..i.. " seconds left!"

	end

	local plyrs  = {}
	for _, player in pairs(game.Players:GetPlayers()) do
		if player then
			table.insert(plyrs, player)
		end
	end
	
	
	Status.Value = "Intermission..."
	wait(2)
	
	Status.Value = "Teleporting players.."
	
	wait(10)
	
	for i, player in pairs(plyrs) do
		if player then 
			local character = player.Character
			if character then
				for i, tile in pairs(Tiles) do
					character.HumanoidRootPart.CFrame = Tiles[i].CFrame
				end
			else
				character.HumanoidRootPart.CFrame = lobbySpawn.CFrame
				table.remove(plyrs,i)
			end
		else
			table.remove(plyrs,i)
		end
	end
	wait(5)
end

Try putting for i = 5, -1 do instead of for i = 5, 0, -1 do

It still doesnt work I’ve tried it

You need to insert a wait(1) in the loop.

Where do i put it, I’ve tried the top still doesnt work

The line after you set Status.Value.

did i do it right?

local Status = game.ReplicatedStorage.Status
local Tiles = game.Workspace.Tiles:GetChildren()
local lobbySpawn = game.Workspace.LobbySpawn

while true do
	
	for i = 5, -1 do
		Status.Value = "Intermission: "..i.. " seconds left!"

	end
	wait(3)

	local plyrs  = {}
	for _, player in pairs(game.Players:GetPlayers()) do
		if player then
			table.insert(plyrs, player)
		end
	end
	
	
	Status.Value = "Intermission..."
	wait(2)
	
	Status.Value = "Teleporting players.."
	
	wait(10)
	
	for i, player in pairs(plyrs) do
		if player then 
			local character = player.Character
			if character then
				for i, tile in pairs(Tiles) do
					character.HumanoidRootPart.CFrame = Tiles[i].CFrame
				end
			else
				character.HumanoidRootPart.CFrame = lobbySpawn.CFrame
				table.remove(plyrs,i)
			end
		else
			table.remove(plyrs,i)
		end
	end
	wait(5)
end

No, you need to put it inside the loop, not outside.

Thanks it works now! Aprreciate the help

1 Like