Why does this only teleport 1 player instead of all?

	players = game.Players:GetChildren()
	local Amount = #players
	for i, Player in pairs(players) do
		CheckPlayers(Amount, false)
		end
		if #players >= 2 then
			CheckPlayers(Amount, true)
			wait(5)
			for i, Player in pairs(players) do
				CountdownFrom(5)
				local Name = Player.Name
				local RandomPlayer = players[math.random(1, #players)]
				local NewTag = ItTag:Clone()
				NewTag.Parent = workspace:WaitForChild(RandomPlayer.Name):WaitForChild("Head")
				NewTag.Adornee = workspace:WaitForChild(RandomPlayer.Name):WaitForChild("Head")
			workspace:WaitForChild(Name):WaitForChild("HumanoidRootPart").CFrame = CFrame.new(workspace:FindFirstChild("MapStart", true).Position)
			break
		end
	end
end

A lot of this code doesn’t even relate to the issue, just wanted to include it just in-case anyone finds some relation.

There is a break in the for loop where you teleport the player, this stops the loop completely after it runs once

2 Likes

game.Players:GetChildren() doesnt work for some reason and you need to use game.Players:GetPlayers() or it could be the break in each loop being falsely fired but front your code that break is needed to repeat the pre game and tp.

As @pexf said in his reply, your for loop exits as soon as the break is called. Any players left in the for loop will not be teleported after the loop runs successfully one time.

	players = game.Players:GetPlayers()
	local Amount = game.Players.NumPlayers

		CheckPlayers(Amount, false)

		if Amount >= 2 then
			CheckPlayers(Amount, true)
			wait(5)
			for i, Player in pairs(players) do
                if Player then
                    CountDownFrom(5) --Im pretty sure you should remove this as it means every 5 seconds it will tp you making it seem only 1 is tped, or you want to delay it which is fine
				    local Name = Player.Name
				    local NewTag = ItTag:Clone()
				    NewTag.Parent = workspace:WaitForChild(Player.Name):WaitForChild("Head")
				    NewTag.Adornee = workspace:WaitForChild(Player.Name):WaitForChild("Head")
			        workspace:WaitForChild(Name):WaitForChild("HumanoidRootPart").CFrame = 
                    CFrame.new(workspace:FindFirstChild("MapStart", true).Position)
                else
                      table.remove(players,i)
                end
             end
		  end

I remade the script for you as there were multiple errors, you shouldnt use a random player as that has a high chance to select the same player every loop and you should stick to the player from the loop.I also made it so it will remove a player if they leave so it wont error then as a result stopping the loop. I also removed the main loop as it doesnt need to be there.I replaced amount with numplayers as its better to use

Remove the break that’s inside the for loop