Teleporting a Player Character Sometimes Doesn’t Work

Hi, I have tried many ways of teleporting a player’s character.
First I tried changing the root part’s position, but I’ve found out that it can be glitchy and make players invisible to others.
After this I tried using PivotTo() on the character but I came across a problem where the character for whatever reason sometimes doesn’t teleport. This happens about 10% of the time.
So now I tried MoveTo(), on the character not the humanoid, and that also has the same problem.
I have a friend who also uses PivotTo() for his game and he also has the exact same problem.

Is there anything I can do about this? Thanks.

Using Character.HumanoidRootPart.CFrame = ... has always worked for me

You could try :SetPrimaryPartCFrame(), but you will need a primary part for the character.

If you are teleporting the player on the server right after they spawn, you should add a RunService.Heartbeat:Wait() before teleporting the player. Doing so makes the code wait for a physics step to complete before continuing.

Sometimes when a player spawns it takes a physics step before the character is fully initialized. If you try to teleport the player before it is initialized, any changes you make gets reset by the server.

Now if the problem is happening after the player has been spawned for a while, then I’m not sure what would be causing the issue. I would have to see your code to help further.

Example of adding RunService.Heartbeat:Wait() before teleporting:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TELEPORT_LOCATION = CFrame.new(Vector3.new(0,1000,0))

Players.PlayerAdded:Connect(function(player: Player)
	player.CharacterAdded:Connect(function(character: Model)
		RunService.Heartbeat:Wait()
		character:PivotTo(TELEPORT_LOCATION)
	end)
end)
1 Like