How do I teleport everyone teleported back

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

  1. What do you want to achieve? Keep it simple and clear!
    I want to teleport everyone I teleported back, not only my character.
  2. What is the issue? Include screenshots / videos if possible!
    Only my character teleports back
    How - YouTube
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried searching devforums

local script

local Player = game.Players.LocalPlayer

local UIS = game:GetService("UserInputService")
local replicated = game:GetService("ReplicatedStorage")

local dest = game.Workspace.TeleportDestination

local Ionioi = replicated:WaitForChild("Teleport")
local debounce = false
local cooldown = 1
local players = game:GetService("Players")
local client = players.LocalPlayer
local character = client.Character
local hrp = character.PrimaryPart

UIS.InputBegan:Connect(function(input,isTyping)
	if isTyping then 
		return
	elseif input.KeyCode == Enum.KeyCode.Q then
		if debounce == false then
			debounce = true
			local currentPosition = hrp.CFrame
			print("you pressed q")
			Ionioi:FireServer()		
			wait(15)
			hrp.CFrame = currentPosition
		end
	end
end)
Ionioi.OnClientEvent:Connect(function()
	wait(cooldown)
	debounce = false
end)

Ionioi is the one that teleports everyone near me.

1 Like

So you want everyone to be teleported to a certain location? You could use a for i,v in pairs() loop to get all the players and teleport them.

You’re only teleporting the local player’s character.

So I tried doing this and It just makes them take turns. What I wanted is to make everyone teleport at the same time and go back to previous position at the same time. Right now they are just taking turns. Do you know how to fix this?

Local Script

local ServerS = game:GetService("ReplicatedStorage")

local Player = game.Players.LocalPlayer

local UIS = game:GetService("UserInputService")
local replicated = game:GetService("ReplicatedStorage")

local dest = game.Workspace.TeleportDestination

local Ionioi = replicated:WaitForChild("Teleport")
local debounce = false
local cooldown = 1

UIS.InputBegan:Connect(function(input,isTyping)
	if isTyping then 
		return
	elseif input.KeyCode == Enum.KeyCode.Q then
		if debounce == false then
			debounce = true
			print("you pressed q")
			Ionioi:FireServer()		
		end
	end
end)
Ionioi.OnClientEvent:Connect(function()
	wait(cooldown)
	debounce = false
end)


ServerScript

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

remote.OnServerEvent:Connect(function(player)
	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 rp =character.HumanoidRootPart
		local rp2 = otherCharacter.HumanoidRootPart

		local distance = 100
		local backdistance = 1000
		if (player.Character.HumanoidRootPart.Position - otherCharacter.HumanoidRootPart.Position).Magnitude <= distance then
			local rPoistion = rp2.CFrame
			local cPosition = rp.CFrame
			otherCharacter:SetPrimaryPartCFrame(Tpto.CFrame*CFrame.new(math.random(1,20),10,math.random(1,20)))
			character:SetPrimaryPartCFrame(userdest.CFrame*CFrame.new(0,10,0))
			character.PrimaryPart.Orientation = character.PrimaryPart.Orientation + Vector3.new(0,270,0)
			wait(10)
			if (player.Character.HumanoidRootPart.Position - otherCharacter.HumanoidRootPart.Position).Magnitude <= backdistance then
				rp.CFrame = cPosition
				rp2.CFrame = rPoistion
							
			end
			
			remote:FireClient(player)
		end
	end
end)```