I have a winner system script which is supposed to insert the names of all players into a table.
The problem with it is that it will only insert a single player into the table.
I tried looking through the Dev Forum, The Wiki, and throughout the internet and found multiple scripts that used to same method as me to accomplish this, but mine didn’t work for some reason.
local round_players = {}
local maps = require(game.ServerScriptService.Maps)
local x = 0
while true do
wait(0)
for i, player in pairs(game.Players:GetPlayers()) do
for i, v in pairs(maps) do
if game.Workspace.MapStorage:FindFirstChild(v) then
local round_players = {}
table.insert(round_players, player.Character.Name)
print(table.concat(round_players))
repeat
wait(1)
x = x+1
print(x)
player.Character.Humanoid.Died:Connect(function()
print(player.Name .. " has died!")
table.remove(round_players, (round_players[player]))
end)
until x == 45
x = 0
msg = ""
for i, playerss in pairs(round_players) do
if player and player.Parent then
if (round_players[1]) and (round_players[2]) and (round_players[3]) and (round_players[4]) and (round_players[5]) and (round_players[6]) and (round_players[7]) and (round_players[8]) and (round_players[9]) and (round_players[10]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])..(round_players[3])..(round_players[4])..(round_players[5])..(round_players[6])..(round_players[7])..(round_players[8])..(round_players[9])..(round_players[10])
elseif (round_players[1]) and (round_players[2]) and (round_players[3]) and (round_players[4]) and (round_players[5]) and (round_players[6]) and (round_players[7]) and (round_players[8]) and (round_players[9]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])..(round_players[3])..(round_players[4])..(round_players[5])..(round_players[6])..(round_players[7])..(round_players[8])..(round_players[9])
elseif (round_players[1]) and (round_players[2]) and (round_players[3]) and (round_players[4]) and (round_players[5]) and (round_players[6]) and (round_players[7]) and (round_players[8]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])..(round_players[3])..(round_players[4])..(round_players[5])..(round_players[6])..(round_players[7])..(round_players[8])
elseif (round_players[1]) and (round_players[2]) and (round_players[3]) and (round_players[4]) and (round_players[5]) and (round_players[6]) and (round_players[7]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])..(round_players[3])..(round_players[4])..(round_players[5])..(round_players[6])..(round_players[7])
elseif (round_players[1]) and (round_players[2]) and (round_players[3]) and (round_players[4]) and (round_players[5]) and (round_players[6]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])..(round_players[3])..(round_players[4])..(round_players[5])..(round_players[6])
elseif (round_players[1]) and (round_players[2]) and (round_players[3]) and (round_players[4]) and (round_players[5]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])..(round_players[3])..(round_players[4])..(round_players[5])
elseif (round_players[1]) and (round_players[2]) and (round_players[3]) and (round_players[4]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])..(round_players[3])..(round_players[4])
elseif (round_players[1]) and (round_players[2]) and (round_players[3]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])..(round_players[3])
elseif (round_players[1]) and (round_players[2]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])..(round_players[2])
elseif (round_players[1]) then
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..(round_players[1])
end
end
end
end
end
end
end
By the way, most of the bottom is completely irrelevant to my problem.If it helps, here’s a photo with the important lines circled. Any help would be appreciated.
Thanks for reading!