Line 115 is the line that lists the players. When 3 people win it will only list 1. I get no errors. I want the players to list out like this: Player1, Player2, Player3. RIght now it looks like this. Player1 and thats it

local LobbyMusicFolder = game.workspace:WaitForChild("LobbyMusic")

local GameMusicFolder = game.workspace:WaitForChild("GameMusic")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local BE = game.ReplicatedStorage:WaitForChild("MapLoader")

local AfkEvent = game.ReplicatedStorage:WaitForChild("AfkEvent")

local Status = game.ReplicatedStorage:WaitForChild("Status")

local MC = workspace:WaitForChild("MapChosen")

function IsOrNotAfkTable(WhichValue)
	local returntab = {}
	for i,v in pairs(game.Players:GetPlayers()) do
		if v.Character ~= nil then
			if v.Afk.Value == WhichValue then
				table.insert(returntab,v)
			end
		end
	end
	return returntab
end

AfkEvent.OnServerEvent:Connect(function(playerwhosent,isafk)
        print(isafk)
        if isafk == true then
            playerwhosent.Afk.Value = true
        elseif isafk == false then
             playerwhosent.Afk.Value = false
        end
    end)

local plrs = {}

local ClonedMap = workspace.MapChosen:FindFirstChildWhichIsA("Model")
	for i, player in pairs(game.Players:GetPlayers()) do
    if player then
       table.insert(plrs, player) -- Add each player into players table
    end
end
			
for i, v in pairs (game.Players:GetPlayers()) do
	local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
		local AvailableSpawnPoints = SpawnPoints:GetChildren()
			if v then
				local character = v.Character
						if character then
							character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
							local GameTag = Instance.new("BoolValue")
    						GameTag.Name = "GameTag"
    						GameTag.Parent = character
   						end					
					end
				end	

local GameMusicChosen = GameMusicFolder:GetChildren()[math.random(1, #GameMusicFolder:GetChildren())]
GameMusicChosen:Play()
for i,v in pairs (game.Workspace.LobbyMusic:GetChildren()) do
	if v.IsPlaying then
		v:Stop()
	end
end

plrs = IsOrNotAfkTable(false)

local GameLength = workspace.MapChosen:FindFirstChildWhichIsA("Model").Info.GameLength.Value
for i = GameLength,1,-1 do
	Status.Value = "("..i..")"
 	for x, player in pairs(plrs) do
        if player then
            local character = player.Character
 
            if not character then
                -- Left the game
                table.remove(plrs,x)
            else
                if character:FindFirstChild("GameTag") then
                    -- They are still alive
                    print(player.Name.." is still in the game!")
                else
                    -- They are dead
                    table.remove(plrs,x)
                    print(player.Name.." has been removed!")
                end
            end
        else
            table.remove(plrs,x)
            print(player.Name.." has been removed!")
			end
		end	
		wait(1)
 
if ClonedMap:FindFirstChild("SpawnPoints") then
    ClonedMap.SpawnPoints:Destroy()
end

if i == 1 then
local function getPlayers()
  local players = game.Players:GetPlayers()
  local tbl = {}

  for _ , player in pairs(players) do
    local character = player.Character or player.CharacterAdded:Wait()
    local gameTag = character:FindFirstChild("GameTag")
     
    if gameTag then
      table.insert(tbl, player.Name)
    end
  end
  return tbl
end
Status.Value = unpack(getPlayers())
	elseif #plrs == 0 then
		Status.Value = "Nobody won!"
		wait(3)
		break
	end
   end

wait(5)

GameMusicChosen:Stop()

BE:Fire()

ClonedMap:Destroy()

MC.Parent = game.ServerStorage

for i, player in pairs (game.Players:GetPlayers()) do
	if IsOrNotAfkTable(true) then
	player:LoadCharacter()
end
end

9 comments

0

I don't see a part where it finds 3 players..?

0

Well its not specificly for 3 players. Its to find all the players that have a gametag. Like have you played epic minigames? At the very end of the round it displays the winners. I wanted something like that

0

Then make the value print the table, because if I am correct, at the end of the game, the table only includes the winners.

0

Uh okay.

0

How would I print the table?

0

Status.Value = (your table name)

0

Without the parentheses.

0

Another way I figured out: Make a folder in ServerStorage called Winners, and detect the winners in this script, and make a StringValue inside the folder for each winner, detect the username of each winner, and put each string value each name of the winner, then make the text print for each value's name.

0

If you want to do the folder, I think the best thing to do is put a for-do statement, making a stringvalue for each winner.