How to set orientation of HumanoidRootPart to a Vector3 direction

This sounds like something extremely easy that can be googled, but everything I tried didn’t work.

What I’m trying to do:
After geting knocked back, the character is down on the ground. When the player tries to move the character, the humanoid’s MoveDirectionProperty changes but the WalkSpeed is 0 to prevent walking. I’m trying to make the character face toward the humanoid’s MoveDirection property before the character rolls.

Example:
This is done with the humanoid’s AutoRotate, not by setting orientation. Turning to the direction is delayed.

Attempts:

  1. Setting the Orientation directly caused the character to face up and glitch in place running.
  2. I tried to make the hrp face a position 1 stud away in the MoveDirection:
    (hum = Humanoid, hrp = HumanoidRootPart)
		local x
		local z
		if hum.MoveDirection.X < 0 then
			x = hum.MoveDirection.X - 1
		else
			x = hum.MoveDirection.X + 1
		end
		if hum.MoveDirection.Z < 0 then
			z = hum.MoveDirection.Z - 1
		else
			z = hum.MoveDirection.Z + 1
		end
		
		print(hrp.Orientation)
		hrp.CFrame = CFrame.new(hrp.Position, Vector3.new(x, hrp.Position.Y, z))
		print(hrp.Orientation)

Result:
Screenshot 2025-10-29 141005


The baseplate isn’t moved up. The hrp is the grey box in the video, it shouldn’t be over 20 studs high.

  1. Making hrp face 2 studs away:
print('MoveDirection '..tostring(hum.MoveDirection))
print('Position '..tostring(hrp.Position))
print(hrp.Orientation)
hrp.CFrame = CFrame.new(hrp.Position, Vector3.new(hum.MoveDirection.X, hrp.Position.Y, hum.MoveDirection.Z) * 2)
print(hrp.Orientation)

Result:
Screenshot 2025-10-29 143245

  1. Setting WalkSpeed to 1000 to make AutoRotate faster and setting it back to 18 right after destroying the roll LinearVelocity
    Result: The WalkSpeed didnt go back to 18 and the character almost ran off the baseplate

The y value should be 0. Help Im stuck T-T

Edit: The roll orientation is wrong in any direction except exactly forward. The MoveDirection property is a Vector3 that changes from movement input (w, a, s, d, mobile/controller joystick)

ok, so to me it looks like you are trying to make the HRP look the right way for the roll, I have two ideas 1. if the player is always facing the wrong when they get kicked so I think you can just do:

HumanoidRootPart.CFrame -= CFrame.fromEulerAngles(0,180,0)

you may be able to use the dot product which is a function on vectors but i’m not a hundred percent on how you get the second vector needed.
Dot product documentation https://create.roblox.com/docs/reference/engine/datatypes/Vector3 (if u scroll down a bit)

1 Like

Thanks but the roll is in any direction the player wants to go. I made it turn backwards for testing because its the biggest angle and easiest to see if something weird happens.

1 Like

You shouldn’t set the orientation or position of an assembly (something connected with constraints like welds or joints) unless you want to have the joints modified (if it’s unintentionally it will end up with wacky constraints, like the torso being separated from the HRP).

Instead, you should directly edit the CFrame.

You can use code like this to set the direction a character/rig is facing based on a direction vector:

local faceTowards = ... -- some vector3 to face towards. Should never be directly above or below the character.
-- (If you want it in a direction do faceTowards = hrp.Position + direction)
local hrp = ... -- your hrp

-- Make faceTowards level with the HRP so the character doesn't tilt up or down
faceTowards = faceTowards - Vector3.new(0, faceTowards.Y, 0) + Vector3.new(0, hrp.Position.Y, 0)

-- Make a CFrame at the HRP's position facing towards the point
hrp.CFrame = CFrame.lookAt(hrp.Position, faceTowards)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.