I'll lay out the basics for you.
Firstly, we want to create local variables. These variables will make things much cleaner and therefore easier to work with.
local Players = game:GetService("Players") - Getting the Players service
local TeleportPad = workspace.GameParts.GamePad - Pointing to the part that we want everybody to teleport to
The next step will be to create a loop so we can go through all the players in the game and do something to them.
for _, player in pairs(Players:GetChildren()) do - The important part to note is the Players:GetChildren() which creates a table of all the Players in the game for us to loop through.
Now for the loop itself. We now want to find the corresponding players character by doing local char = player.Character or player.CharacterAdded:Wait()
This will either immediately find the players character or (if it cannot find the player) wait until the player has spawned in, after which, get the HumanoidRootPart - the part we will be teleporting. local torso = char:FindFirstChild("HumanoidRootPart")
Finally, we check to see whether the HumanoidRootPart actually exists. If it does, the player will be teleported to the position mentioned at the start.
if torso then
torso.Position = TeleportPad.Position
end
The full code:
local Players = game:GetService("Players")
local TeleportPad = workspace.GameParts.GamePad
for _, player in pairs(Players:GetChildren()) do
local char = player.Character or player.CharacterAdded:Wait()
local torso = char:FindFirstChild("HumanoidRootPart")
if torso then
torso.Position = TeleportPad.Position
end
end
4 comments
Context is important. Why do you want to teleport everybody - What triggers the players to teleport - Are you using a ServerScript/LocalScript
i've updated it, i hope that helps
You intended it to teleport all the players when you touched the part or some gui or chat command?
It's a round game, so it's intended to teleport players into the round automatically when a new round is starting up