Could someone are knowing how a script can teleport all players to a same part?

Actually i have maid this script , but it only teleport one player …

local Players = Game:GetService("Players")
local Tppart = game.Workspace.TpFolder.TpPart1

for i,v in pairs(Players:GetChildren()) do
			local char = v.Character
			if char then
				char.HumanoidRootPart.CFrame = Tppart.CFrame
			end

So if someone can help me , that could be perfect !

This may seem like a really dumb question, but you tried with multiple player in the game right? And are there any errors in output?
I suggest you using

local char = v.CharacterAdded:Wait()

It is a little bit better.

This script is a server script right? If not, then you have your issue.

local function TeleportAll(Plyrs, TpPart)
	for i, v in pairs(Plyrs) do
		local Character = v.Character
		if not Character then continue end
		local HumanoidRootPart = v.Character:FindFirstChild("HumanoidRootPart")
		if not HumanoidRootPart then continue end
		HumanoidRootPart.CFrame = TpPart.CFrame
	end
end


TeleportAll(game.Players:GetPlayers(), workspace.Baseplate)

Won’t change, and did he realized that he needed a “end” at the end?
Because it seems he forgot it.

Its not working , actually my script look like that :

Tp = function()

-- locals

for i,v in pairs(Players:GetChildren()) do
			local char = v.CharacterAdded:Wait()
			if char then
				char.HumanoidRootPart.CFrame = Tppart.CFrame
			end

-- script

	end
	end,

Tnks but nah , that won’t change anything

It works… figure it out :slight_smile:

TeleportAll(game.Players:GetPlayers(), Tppart)

1 Like

Oh ye you are right it worked!

Code Simplification:

local Array = Players:GetPlayers()

for _,p in Array do
    if p.Character then
        p.Character:PivotTo(Tppart.CFrame)
    end
end