Only Teleports 1 player bug (in game teleportation)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want a round system that be able to teleports all players in game to the certain position

  2. What is the issue?
    it only teleports 1 player even though there more than 1 players

  3. What solutions have you tried so far?
    I already looking at somewhere website but looks like couldnt found any

Heres the Codes

local roundLength = 50
local intermissionLength = 20
local SplitUpTime = 4
local inRound = game.ReplicatedStorage.InRound
local SpawnLocation1 = game.Workspace.SpawnLocation3
local status = game.ReplicatedStorage.Status
local startgameSafe = {game.Workspace.SafeStartGame}
local mapsFolder = game.ReplicatedStorage.Maps
local Maps = mapsFolder:GetChildren()
local FightArea2 = game.Workspace.FightArea2
local FightArea3 = game.Workspace.FightArea3

while task.wait() do

	local plrs = {}

	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
			table.insert(plrs,player)
		end
	end

	for i = intermissionLength, 0, -1 do
		task.wait(1)
		status.Value = "Intermission: " .. i .. " seconds left"
	end
	local chosenMap = Maps[math.random(1, #Maps)]
	local ClonedMap = chosenMap:Clone()
	ClonedMap.Parent = game.Workspace
	for i = 2, 0, -1 do
		task.wait(1)
		status.Value = chosenMap.Name.." has been chosen!"
	end
	for i = 3, 0, -1 do
		task.wait(1)
		status.Value = "Teleporting players in "..i
	end
	--wait(0.1)
	local player = game:GetService("Players"):GetChildren()
	for i = 1, #player do
		if game.Workspace:FindFirstChild("Old Roblox") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				local OldRobloxSpawnPoints = game.Workspace.OldRobloxSpawnPoints:GetChildren()
				char.HumanoidRootPart.CFrame = OldRobloxSpawnPoints[math.random(1, #OldRobloxSpawnPoints)].CFrame + Vector3.new(0,3,0)
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		elseif game.Workspace:FindFirstChild("Lost Arena") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				char.HumanoidRootPart.CFrame = FightArea2.CFrame
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		elseif game.Workspace:FindFirstChild("Season Memory") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				char.HumanoidRootPart.CFrame = FightArea3.CFrame
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		elseif game.Workspace:FindFirstChild("Zoyna Grass") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				local availableSpawnPoints = game.Workspace.AvailableSpawnPoints:GetChildren()

				char.HumanoidRootPart.CFrame = availableSpawnPoints[math.random(1, #availableSpawnPoints)].CFrame + Vector3.new(0,10,0)
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		elseif game.Workspace:FindFirstChild("Sky Temple") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				local SkyTempleSpawnPoints = game.Workspace.TempleSpawnPoints:GetChildren()

				char.HumanoidRootPart.CFrame = SkyTempleSpawnPoints[math.random(1, #SkyTempleSpawnPoints)].CFrame
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		end
		for i, v in pairs(startgameSafe) do
			if game.Workspace:FindFirstChild("Old Roblox") then
				while true do
					local cloening = v:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(444.831, 95.892, -244.572)
					cloening.Size = Vector3.new(382.31, 211.879, 375.354)
					for x = SplitUpTime, 0, -1 do
						task.wait(1)
						status.Value = "Split up..("..x..")"
					end
					cloening:Destroy()
					break
				end
				while true do
					local cloening = game.Workspace.KillStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(398.001, -11.997, -119.506)
					cloening.Size = Vector3.new(250, 127.75, 230.5)
					task.wait(1)
					cloening:Destroy()
					break
				end
			elseif game.Workspace:FindFirstChild("Lost Arena") then
				while true do
					local cloening = game.Workspace.SafeStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(398.399, 68.09, 153.936)
					cloening.Size = Vector3.new(174, 159, 200)
					for x = SplitUpTime, 0, -1 do
						task.wait(1)
						status.Value = "Split up..("..x..")"
					end
					cloening:Destroy()
					break
				end
				while true do
					local cloening = game.Workspace.KillStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(398.399, 68.09, 153.936)
					cloening.Size = Vector3.new(174, 159, 200)
					task.wait(1)
					cloening:Destroy()
					break
				end
			elseif game.Workspace:FindFirstChild("Season Memory") then
				while true do
					local cloening = game.Workspace.SafeStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(111.937, 94.313, 269.332)
					cloening.Size = Vector3.new(152.436, 136.67, 164.749)
					for x = SplitUpTime, 0, -1 do
						task.wait(1)
						status.Value = "Split up..("..x..")"
					end
					cloening:Destroy()
					break
				end
				while true do
					local cloening = game.Workspace.KillStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(111.937, 94.313, 269.332)
					cloening.Size = Vector3.new(152.436, 136.67, 164.749)
					task.wait(1)
					cloening:Destroy()
					break
				end
			elseif game.Workspace:FindFirstChild("Zoyna Grass") then
				while true do
					local cloening = game.Workspace.SafeStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(-126.102, 39.862, 307.741)
					cloening.Size = Vector3.new(209.931, 125.686, 211.61)
					for x = SplitUpTime, 0, -1 do
						task.wait(1)
						status.Value = "Split up..("..x..")"
					end
					cloening:Destroy()
					break
				end
				while true do
					local cloening = game.Workspace.KillStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(-126.102, 39.862, 307.741)
					cloening.Size = Vector3.new(209.931, 125.686, 211.61)
					task.wait(1)
					cloening:Destroy()
					break
				end
			elseif game.Workspace:FindFirstChild("Sky Temple") then
				while true do
					local cloening = game.Workspace.SafeStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(-386.566, 22.128, 23.452)
					cloening.Size = Vector3.new(290.586, 208.991, 281.654)
					for x = SplitUpTime, 0, -1 do
						task.wait(1)
						status.Value = "Split up..("..x..")"
					end
					cloening:Destroy()
					break
				end
				while true do
					local cloening = game.Workspace.KillStartGame:Clone()
					cloening.Parent = game.Workspace
					cloening.Position = Vector3.new(-386.566, 22.128, 23.452)
					cloening.Size = Vector3.new(290.586, 208.991, 281.654)
					task.wait(1)
					cloening:Destroy()
					break
				end
			end
		end
		for i = roundLength, 0, -1 do
			
			for x, players in pairs(plrs) do
				if players then
					character = players.Character
					
					if not character then
						table.remove(plrs,x)
					else
						if character:FindFirstChild("GameTag") then
							print(players.Name.." are still in game!")
						else
							table.remove(plrs,x)
							print(players.Name.." are removed from the game")
						end
					end
				else
					table.remove(plrs,x)
					print(players.Name.. " has been removed from the game!")
				end
			end
			status.Value = "Game ends in ".. i .. " seconds"
			
			if game.Players.NumPlayers == 1 then
				if #plrs == 0 then
					status.Value = "No Winner!"
					break
				elseif i == 0 then
					status.Value = "Time's up!"
				end
			elseif game.Players.NumPlayers >= 2 then
				if #plrs == 1 then
					status.Value = "Winner : ".. plrs[1].Name.."!"
					plrs[1].Money.Value = plrs[1].Money.Value + 20
					plrs[1].Exp.Value = plrs[1].Exp.Value + 50
					plrs[1].leaderstats.Wins.Value = plrs[1].leaderstats.Wins.Value + 1
					break
				elseif i == 0 then
					status.Value = "Time's up!"
					break
				end
			end
			task.wait(1)
		end
		local players = game:GetService("Players"):GetChildren()
		for i = 1, #player do
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				char.HumanoidRootPart.CFrame = SpawnLocation1.CFrame + Vector3.new(0,2,0)
			end
		end
		for i, players in pairs(game.Players:GetChildren()) do
			Char = players.Character

			if not Char then

			else
				if Char:FindFirstChild("GameTag") then
					Char.GameTag:Destroy()
				end
			end
		end
		
		local Debris = game:GetService("Debris")
		
		if game.Workspace:FindFirstChild("Old Roblox") then
			Debris:AddItem(game.Workspace["Old Roblox"],0)
			
		elseif game.Workspace:FindFirstChild("Lost Arena") then
			Debris:AddItem(game.Workspace["Lost Arena"],0)
			
		elseif game.Workspace:FindFirstChild("Season Memory") then
			Debris:AddItem(game.Workspace["Season Memory"],0)
			
		elseif game.Workspace:FindFirstChild("Zoyna Grass") then
			Debris:AddItem(game.Workspace["Zoyna Grass"],0)
			
		elseif game.Workspace:FindFirstChild("Sky Temple") then
			Debris:AddItem(game.Workspace["Sky Temple"],0)
			
		end
	end
end

Did you write the code? If not, you should ask the person who wrote it to try to debug it first.

You supplied way too much code to sift through. To start debugging, Iā€™d print out the list of players when they are supposed to be teleported to see if it is related to the way you are trying to teleport players, or if it is the way you are storing them in a list.

1 Like

Yes I wrote this whole lines of codes

Do you get any errors in console when playing the game? Check both the client & server tab.

Theres no any errors in client and server

I just figured it out!

local intermissionLength = 20
local SplitUpTime = 4
local inRound = game.ReplicatedStorage.InRound
local SpawnLocation1 = game.Workspace.SpawnLocation3
local status = game.ReplicatedStorage.Status
local startgameSafe = {game.Workspace.SafeStartGame}
local mapsFolder = game.ReplicatedStorage.Maps
local Maps = mapsFolder:GetChildren()
local FightArea2 = game.Workspace.FightArea2
local FightArea3 = game.Workspace.FightArea3

while true do

	task.wait()

	local plrs = {}

	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
			table.insert(plrs,player)
		end
	end

	for i = intermissionLength, 1, -1 do
		task.wait(1)
		status.Value = "Intermission: " .. i .. " seconds left"
	end
	local chosenMap = Maps[math.random(1, #Maps)]
	local ClonedMap = chosenMap:Clone()
	ClonedMap.Parent = game.Workspace
	for i = 2, 1, -1 do
		task.wait(1)
		status.Value = chosenMap.Name.." has been chosen!"
	end
	for i = 3, 1, -1 do
		task.wait(1)
		status.Value = "Teleporting players in "..i
	end

	local player = game.Players:GetChildren()

	for i = 1, #player do
		if game.Workspace:FindFirstChild("Old Roblox") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				local OldRobloxSpawnPoints = game.Workspace.OldRobloxSpawnPoints:GetChildren()
				char:FindFirstChild("HumanoidRootPart").CFrame = OldRobloxSpawnPoints[math.random(1, #OldRobloxSpawnPoints)].CFrame + Vector3.new(0,3,0)
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		elseif game.Workspace:FindFirstChild("Lost Arena") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				char:FindFirstChild("HumanoidRootPart").CFrame = FightArea2.CFrame
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		elseif game.Workspace:FindFirstChild("Season Memory") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				char:FindFirstChild("HumanoidRootPart").CFrame = FightArea3.CFrame
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		elseif game.Workspace:FindFirstChild("Zoyna Grass") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				local availableSpawnPoints = game.Workspace.AvailableSpawnPoints:GetChildren()

				char:FindFirstChild("HumanoidRootPart").CFrame = availableSpawnPoints[math.random(1, #availableSpawnPoints)].CFrame + Vector3.new(0,10,0)
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		elseif game.Workspace:FindFirstChild("Sky Temple") then
			if player[i].afkMode.Value == true then

			else
				local char = player[i].Character
				local SkyTempleSpawnPoints = game.Workspace.TempleSpawnPoints:GetChildren()

				char:FindFirstChild("HumanoidRootPart").CFrame = SkyTempleSpawnPoints[math.random(1, #SkyTempleSpawnPoints)].CFrame
				local Gametag = Instance.new("BoolValue")
				Gametag.Name = "GameTag"
				Gametag.Parent = char
			end
		end
	end

	if game.Workspace:FindFirstChild("Old Roblox") then
		
		local cloening = game.Workspace.KillStartGame:Clone()
		cloening.Parent = game.Workspace
		cloening.Position = Vector3.new(444.831, 95.892, -244.572)
		cloening.Size = Vector3.new(382.31, 211.879, 375.354)
		for x = SplitUpTime, 1, -1 do
			task.wait(1)
			status.Value = "Split up..("..x..")"
		end
		cloening:Destroy()

		local CLONING = game.Workspace.KillStartGame:Clone()
		CLONING.Parent = game.Workspace
		CLONING.Position = Vector3.new(398.001, -11.997, -119.506)
		CLONING.Size = Vector3.new(250, 127.75, 230.5)
		task.wait(1)
		CLONING:Destroy()

	elseif game.Workspace:FindFirstChild("Lost Arena") then
		
		local cloening = game.Workspace.SafeStartGame:Clone()
		cloening.Parent = game.Workspace
		cloening.Position = Vector3.new(398.399, 68.09, 153.936)
		cloening.Size = Vector3.new(174, 159, 200)
		for x = SplitUpTime, 1, -1 do
			task.wait(1)
			status.Value = "Split up..("..x..")"
		end
		cloening:Destroy()
		
		local CLONING = game.Workspace.KillStartGame:Clone()
		CLONING.Parent = game.Workspace
		CLONING.Position = Vector3.new(398.399, 68.09, 153.936)
		CLONING.Size = Vector3.new(174, 159, 200)
		task.wait(1)
		CLONING:Destroy()
		
	elseif game.Workspace:FindFirstChild("Season Memory") then
		
		local cloening = game.Workspace.SafeStartGame:Clone()
		cloening.Parent = game.Workspace
		cloening.Position = Vector3.new(111.937, 94.313, 269.332)
		cloening.Size = Vector3.new(152.436, 136.67, 164.749)
		for x = SplitUpTime, 1, -1 do
			task.wait(1)
			status.Value = "Split up..("..x..")"
		end
		cloening:Destroy()

		local CLONING = game.Workspace.KillStartGame:Clone()
		CLONING.Parent = game.Workspace
		CLONING.Position = Vector3.new(111.937, 94.313, 269.332)
		CLONING.Size = Vector3.new(152.436, 136.67, 164.749)
		task.wait(1)
		CLONING:Destroy()

	elseif game.Workspace:FindFirstChild("Zoyna Grass") then
		
		local cloening = game.Workspace.SafeStartGame:Clone()
		cloening.Parent = game.Workspace
		cloening.Position = Vector3.new(-126.102, 39.862, 307.741)
		cloening.Size = Vector3.new(209.931, 125.686, 211.61)
		for x = SplitUpTime, 1, -1 do
			task.wait(1)
			status.Value = "Split up..("..x..")"
		end
		cloening:Destroy()

		local CLONING = game.Workspace.KillStartGame:Clone()
		CLONING.Parent = game.Workspace
		CLONING.Position = Vector3.new(-126.102, 39.862, 307.741)
		CLONING.Size = Vector3.new(209.931, 125.686, 211.61)
		task.wait(1)
		CLONING:Destroy()

	elseif game.Workspace:FindFirstChild("Sky Temple") then
		
		local cloening = game.Workspace.SafeStartGame:Clone()
		cloening.Parent = game.Workspace
		cloening.Position = Vector3.new(-386.566, 22.128, 23.452)
		cloening.Size = Vector3.new(290.586, 208.991, 281.654)
		for x = SplitUpTime, 1, -1 do
			task.wait(1)
			status.Value = "Split up..("..x..")"
		end
		cloening:Destroy()

		local CLONING = game.Workspace.KillStartGame:Clone()
		CLONING.Parent = game.Workspace
		CLONING.Position = Vector3.new(-386.566, 22.128, 23.452)
		CLONING.Size = Vector3.new(290.586, 208.991, 281.654)
		task.wait(1)
		CLONING:Destroy()

	end

	for i = roundLength, 1, -1 do

		for x, players in pairs(plrs) do
			if players then
				character = players.Character

				if not character then
					table.remove(plrs, x)
				else
					if character:FindFirstChild("GameTag") then
						print(players.Name.." are still in game!")
					else
						table.remove(plrs,x)
						print(players.Name.." are removed from the game")
					end
				end
			else
				table.remove(plrs,x)
				print(players.Name.. " has been removed from the game!")
			end
		end
		
		status.Value = "Game ends in ".. i .. " seconds"

		if #player == 1 then

			if #plrs == 0 then
				status.Value = "All players has died"
				break
			elseif i == 0 then
				status.Value = "Time's up!"
				break
			end

		elseif #player >= 2 then
			
			if #plrs == 1 then

				status.Value = "Winner : ".. plrs[1].Name.."!"
				plrs[1].Money.Value += 20
				plrs[1].Exp.Value += 50
				plrs[1].leaderstats.Wins.Value += 1
				break

			elseif i == 0 then

				status.Value = "Time's up!"
				break
				
			elseif #plrs == 0 then
				status.Value = "All players has died"
				break
			end
		end
		task.wait(1)
	end


	for i = 1, #player do
		if player[i].afkMode.Value == true then

		else
			local char = player[i].Character
			char:FindFirstChild("HumanoidRootPart").CFrame = SpawnLocation1.CFrame + Vector3.new(0,2,0)	
		end
	end

	for i, players in pairs(game.Players:GetPlayers()) do
		Char = players.Character

		if not Char then

		else
			if Char:FindFirstChild("GameTag") then
				Char.GameTag:Destroy()
			end
		end
	end
	
	if game.Workspace:FindFirstChild("Old Roblox") then
		game.Workspace["Old Roblox"]:Destroy()
	end

	if game.Workspace:FindFirstChild("Lost Arena") then
		game.Workspace["Lost Arena"]:Destroy()
	end

	if game.Workspace:FindFirstChild("Season Memory") then
		game.Workspace["Season Memory"]:Destroy()
	end

	if game.Workspace:FindFirstChild("Zoyna Grass") then
		game.Workspace["Zoyna Grass"]:Destroy()
	end

	if game.Workspace:FindFirstChild("Sky Temple") then
		game.Workspace["Sky Temple"]:Destroy()
	end
end