How do I teleport everyone instead of only 1?

So this script is supposed to make it so that everyone near me will teleport somewhere. But what it’s doing is teleporting only 1 person. I’m pretty new to scripting so if anyone knows how I can fix this please tell me. Thanks.

Server Script:

local players = game:GetService("Players")
local replicated = game:GetService("ReplicatedStorage")
local remote = replicated.Teleport
local destination = game.Workspace.TeleportDestination
local userdest = game.Workspace.userdest
local Tpto = game.Workspace.TeleportDestination

	if not player then return end
	local character = player.Character
	if not character then return end
	local root = character.PrimaryPart
	if not root then return end
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid then return end
	if humanoid.Health <= 0 then return end

	for _, otherPlayer in ipairs(players:GetPlayers()) do
		if not otherPlayer then continue end
		local otherCharacter = otherPlayer.Character
		if not otherCharacter then continue end
		local otherRoot = otherCharacter.PrimaryPart
		if not otherRoot then continue end
		local otherHumanoid = otherCharacter:FindFirstChildOfClass("Humanoid")
		if not otherHumanoid then continue end
		if otherHumanoid.Health <= 0 then continue end
		local distance = 100
		local backdistance = 1000
		if (player.Character.HumanoidRootPart.Position - otherCharacter.HumanoidRootPart.Position).Magnitude <= distance then
			character.PrimaryPart.Orientation = character.PrimaryPart.Orientation +,270,0)

Replace remote:FireClient() with remote:FireAllClients()


I tried this it didn’t work, it still teleported only 1 player


does it error after looping once or something so it only teleports one?


Wait I just tried it again, now it doesn’t even teleport anyone else anymore it just teleports my player

1 Like

nvm now its working again, but it still just teleports 1 and there are no errors

1 Like

Maybe because its tping the player who fired the event first, then the other players are too far away for get tped?

1 Like

Here, you are getting game.Workspace.TeleportDestination on Tpto AND destination, look:

local destination = game.Workspace.TeleportDestination
local Tpto = game.Workspace.TeleportDestination

Yes I already removed 1 of them but it still teleports only 1 other player.


Wouldnt you just do a for loop and get all the players and get their Root parts and then change the CFrame of the root part to where you want the characters to go, or is that not working?


You could try and loop through all existing players, then find their character. As @C_ozmo said, you would get their Root parts and place their CFrames to your teleport location.

for _, player in pairs(game:GetService("Players"):GetPlayers() do --Loops through al the players
   local character = player.Character or player.CharacterAdded:Wait() --//Gets the character from the player
   local root = character:WaitForChild("HumanoidRootPart") --//Gets the HumanoidRootPart

   root.CFrame = destination.CFrame --//Sets the HumanoidRootPart to your teleport location

Yeah I think thats what the code already does. I think. But it just teleports 1 other player besides me. I tried making it a for loop but it makes them teleport separately 1 at a time and not all at the same time. (sorry im pretty new to this and I’m not really sure about the codes)


I tried making a for loop but it just teleports them separately 1 at a time. Is there a way to make them teleport all at once?


How many players are you testing with? If you’re testing with one other player, it’s going to look like as if only one other player is being teleported to you. If you maybe test with two other players, you could get a better result.

1 Like

How long is the intervals between teleportation? is there a notable difference?


im testing with 3 players and it only teleports 1 other player. Or 2 if u count my player

1 Like

I didn’t put any intervals. (idk what intervals really mean but Im just guessing that intervals means like the wait() function tell me if im wrong pls)

1 Like

Try printing out each player name in the for loop to see how many times your loop is running. That could help out.


For I, v in pairs(game.Players:GetChildren()) do

1 Like

I tried putting a wait() function and it teleports everyone but only 1by 1. I really don’t know why it teleports everyone else when I add a wait() function and why it wont teleport everyone when I remove the wait() function. teleport problem - YouTube