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
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