Edit:
01 | alive = { } |
02 |
03 | for i,v in pairs (game.Players:GetPlayers()) do |
04 | if v:FindFirstChild( "InGame" ) then |
05 | v.InGame.Value = true |
06 | table.insert(alive, i) |
07 | end |
08 | end |
09 |
10 |
11 | for i = 1 , 120 do |
12 | if #alive = = 1 then |
13 | for i,v in pairs (game.Players:GetPlayers()) do |
14 | if v:FindFirstChild( "PlayerGui" ) then |
15 | v.PlayerGui.timer.Frame.timer.Text = (alive [ 1 ] .. "Has won!" ) |
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
1 | for i,v in pairs (game.Players:GetPlayers()) do |
2 | if v.InGame.Value = = false then |
3 | table.remove(alive, i) |
4 | end |
5 | end |
To
1 | for _, v in pairs (game.Players:GetPlayers()) do |
2 | if v.InGame.Value = = false then |
3 | for i, z in ipairs (alive) do |
4 | if ( not z) or v = = z then |
5 | table.remove(alive, i) |
6 | end |
7 | end |
8 | end |
9 | end |
Try this in line 02
if #alive < 1 then