How to teleport all players to a random part?

Hello, I’m making a obby but I need help.

I placed the teleporters in a folder and each player must be teleported to a different random part.

If a player was already teleported to one of those then the next player will be teleported to a different random part and so on.

1 Like

Just get all the player’s humanoid root parts and change the cfrmaes to the cframe of the part.

1 Like
for i, v in pairs(game.Players:GetPlayers()) do
if v.Character:FindFirstChild("HumanoidRootPart") then
v.Character.HumanoidRootPart.CFrame = CFrame.new(teleportPart.Position)
end
end

edit: don’t make the teleportpart’s position be in the ground deeply in or they’ll fall off the map and die to their death unfairly if there’s no catch zone

4 Likes

You can have a Folder in workspace with all your parts, and loop through them to pick one, and teleport all player s to that chosen one.

local PartsFolder = game:GetService("Workspace").Folder -- Your Folder
local Players = game:GetService("Players") 

for i, plr in pairs(Players:GetPlayers()) do 
		if plr.Character or plr.CharacterAdded:Wait() then -- Waiting for character to exist
		local HRP = plr.Character:WaitForChild("HumanoidRootPart") 
		local Parts = PartsFolder:GetChildren() -- Getting chidren(parts) of the folder
		HRP.CFrame = Parts[math.random(1,#Parts)].CFrame + Vector3.new(0,5,0) -- picking a random part and teleporting with HRP 
	end
end
3 Likes