Edit:
alive = {} for i,v in pairs(game.Players:GetPlayers()) do if v:FindFirstChild("InGame") then v.InGame.Value = true table.insert(alive, i) end end for i = 1,120 do if #alive == 1 then for i,v in pairs(game.Players:GetPlayers()) do if v:FindFirstChild("PlayerGui") then v.PlayerGui.timer.Frame.timer.Text = (alive[1] .. "Has won!") end end break end if #alive == 0 then break end for _, v in pairs(game.Players:GetPlayers()) do if v.InGame.Value == false then for i, z in ipairs(alive) do if (not z) or v == z then table.remove(alive, i) end end end end wait(1) end
Your problem is actually in the first block of code you posted:
Change table.insert(alive, i)
to table.insert(alive, v)
.
You're inserting the index of the player in the GetPlayers table, instead of the Player themselves.
Edit 2: Change
for i,v in pairs(game.Players:GetPlayers()) do if v.InGame.Value == false then table.remove(alive, i) end end
To
for _, v in pairs(game.Players:GetPlayers()) do if v.InGame.Value == false then for i, z in ipairs(alive) do if (not z) or v == z then table.remove(alive, i) end end end end
Try this in line 02
if #alive < 1 then