Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to teleport a player at a specific place?

local plr = game:GetService("Players")

local function transfer()
	for i,v in pairs (plr:GetPlayers()) do 
		if v.Character then
			if v.Character:FindFirstChild("Humanoid") then
				v.Character:FindFirstChild("Humanoid"):MoveTo(Vector3(-20.25, 20.5, 290.25))
			end
		end
	end
end

transfer()

Can anybody help me correct my script and is it right that I should put it in the serverscriptserver?

1 comment

0

Click the blue lua button to write scripts

2 answers

you could try this:

local player = game:GetPlayers()
target = CFrame.new(-20.25, 20.5, 290.25) 
for i, player in ipairs(game.Players:GetChildren()) do
   if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
      player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
   end
end

if you are trying to teleport all players, im pretty sure you have to use CFrame like the example above. Hope this helps! also i think this need to be in servscriptservice.

If you want to move a player without resetting their avatar it is better to move their torso instead.

Be sure to get the torso position using a rig

local plr = game:GetService("Players").LocalPlayer
	
local function transfer()
	local character = plr.CharacterAdded:Wait or plr.Character
	character:FindFirstChild("Torso").Position = Vector3.new(--Position where the player's torso will go)
	end

transfer()

-- If this is what you need, the function will run immediately a player's character joins the game

I hope this helps

This discussion is preserved as it was. New answers, comments, and votes are closed.