Player doesn't change orientation when teleported

I’m making a Speed Run game in which you finish a level and move on to the next one by touching a portal. Right now you face whatever direction you were facing when you entered, but I want players to be orientated to face forward so they don’t have to turn and figure out where they are.

I tried doing this by changing HumanoidRootPart’s orientation, as well as torso but neither worked.

1 Like

Use CFrame.Angles.

HumanoidRootPart.CFrame *= CFrame.Angles()

Or, you can use it when you teleport the player to the area through the 2nd paramater of CFrame.new

HumanoidRootPart.CFrame = CFrame.new(position, orientation)
1 Like

I tried replacing where I changed the rootpart position with that bottom one but it still didn’t rotate my character in the direction it was supposed to

Can I see the script where you teleport the player?

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
		hit.Parent.HumanoidRootPart.Position = game.Workspace.Checkpoints.Checkpoint3.Position + Vector3.new(0,5)
	end
end)

Alright, there are a few things that I would fix about this.

  1. Use the HumanoidRootPart’s CFrame as Position can sometimes break the character
  2. You are just adding to the Position when you do +Vector3.new(0,5) and Vector3.new() uses 3 paramaters not just 2
script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
		hit.Parent.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.Checkpoints.Checkpoint3.Position, Vector3.new(0,5,0))
	end
end)

What would I change to rotate the character…?

You would change the Vector3.new()

You could also change the Vector3.new() to workspace.Checkpoints.Checkpoint3.Orientation if it is facing the way the player would need to go.

local goal = Vector3.new(x, y, z) --Replace these variables ​ (orientation)
local goalposition = Vector3.new(x, y, z) --Replace these too (position)
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild(“HumanoidRootPart”) then
local hp = hit.Parent.HumanoidRootPart
hp.CFrame = CFrame.new(goalposition.X, goalposition.Y,goalposition.Z) * CFrame.Angles(math.rad(goal.X), math.rad(goal.Y), math.rad(goal.Z))
end
end

Try this:

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
		hit.Parent.HumanoidRootPart.CFrame = game.Workspace.Checkpoints.Checkpoint3.CFrame * CFrame.Angles(0,math.rad(From 0 to 360),0) + Vector3.new(0,5,0)
	end
end) 
1 Like