table.insert isn't your problem; you're using it correctly. However, there are other problems with this, and you may not even need to use it:
The code which checks for the PlayersInMatch runs once, when the script is first ran. The amount of players on the team at that time is most likely zero; server scripts run before local scripts do because the server loads before the player.
When you call GetPlayers(), it returns a table of players in that team. This table does not change when the amount of players in that team changes, PlayersInMatch is still the amount of players on the team when you called it.
You can remedy this by moving that code to the appropriate location, so that it gets the amount of players within the loop, instead of only once, when the script runs.
There's also an issue with the way you use table.concat; if the code were to behave as you thought, table.concat would have tried to concatenate a userdata value (the Player), which would have caused an error. Really, you don't even need that here at all, what you may have been looking for is tostring[^1].
Lastly, a small logic error, your code assumed that there's at least one player left, but there could be no players left. You can easily handle this, as well.
local Winner;
for i = 200,1,-1 do
local PlayersInMatch = game.Teams.Duelers:GetPlayers()
if #PlayersInMatch <= 1 then
Winner = PlayersInMatch[1];
break
end
status.Value = "Time Left: "..i
wait(1)
end
status.Value = (Winner) and ("Game End! The Winner is "..tostring(Winner)) or ("No one survived!")
Notice how your code looks a bit cleaner? I fixed it for you this time, but please be sure to properly indent your code in the future.
Hope this helped.
PS: You can read more about the ternary operator I used above, if you'd like.
[^1]: Read more about the tostring function.
2 comments
There is an edit button; you didn't have to delete your question and repost it.
Just noticed that lol