How would I make a character Root Motor6d's rotation face flat with the ground below it, while still keeping it original Y Orientation

So, say this is my character
image
and it was positioned on a slope like this
image

How would I make it so it takes the LowerTorso’s Motor6d called “Root” to face flat with the ground like the player’s feet are stinking to it, here is a picture for example.

So this transfers to this
image
-vv-vv-
image
And this one as well
image
-vv-vv-
image

So I want it to keep its original Orientation while combining it with the angle of the slope.

1 Like

I got the CFrames position and rotation to work on a part that doesn’t have a motor connected to it. Here is a video of that

However, when I apply the code to a motor6d on a character It seems to multiply the Y Axis’s rotation by 2

This I part of my code for the the rotation

local groundRay = CreateRay(Root.Position,Root.Position + Root.CFrame.UpVector*-5,Character:GetDescendants(),Enum.RaycastFilterType.Exclude,nil,false)
				
				if groundRay then
					
					local Look = groundRay.Normal:Cross(Root.CFrame.RightVector)
					local finalCFrame = CFrame.lookAt(Vector3.zero, Look, groundRay.Normal)
					
					
					TweenService:Create(Joints.RootJoint.Joint, TweenInfo.new(0.1),{C0 = finalCFrame}):Play()
end

How would I stop the Y axis from being not accurate with where the humanoid root part is facing?