How can I rotate the character while ignoring the Y value

Hey so I was wondering how can I rotate a character left / right but keep the characters up/down tilt thank you.

BasePart.Orientation = Vector3.new(newRoatation, BasePart.Orientation.Y, newRotation)

If I remember, I think the Y axis is left and right, so you might need to just change that.

1 Like

Yes, the Y axis is the left-right one (if watched from the side (when watched from X/Z))

is there anyway to do this using cframes instead of orientation?

e.g getting the rotation of one cframe and setting the characters cframe to that cframes rotation without adjusting the up/down values.

X, Y or Z axis?
I don’t understand sorry

If you mean changing the orientation to another part’s one then simply store it as a Variable if you want it to stay the same or simply do part.Orientation.Axis to get it

1 Like

Its not another part its just a cframe.
the Y axis.

yes, but it is slightly more complicated than with Vector3 as CFrame uses Radians as its measurement instead of degrees, so we if you want it to function the same, we would need to convert Degrees into Radians using math.rad(), and if you want to convert Radians to Degrees, you use math.deg()

Example:

local x,y,z = workspace.Baseplate.CFrame.Rotation:ToOrientation() -- Rotation of Object (translated)

print(math.deg(x),math.deg(y),math.deg(z)) -- Rotation in Degrees

-- Method 1:
BasePart.CFrame = BasePart.CFrame * CFrame.Angles(math.rad(xValue), y,math.rad(zValue))

-- Method 2:
BasePart.CFrame *= CFrame.Angles(math.rad(xValue), y,math.rad(zValue))

I used the Baseplate as an Example.

However let me if you can simplfy this.


Edit:

No, I was wrong here, all you can do is this:

BasePart.CFrame *= CFrame.Angles(math.rad(xValue), 0, math.rad(zValue))

Because you are essentially Adding into the Value and not replacing it.

I think if you are trying to completely change it, then you would do the other method, or you can get the Values from the Vector3 value (Orientation) and apply them onto the CFrame.

local r = workspace.Baseplate.Orientation -- rotation (Vector3)

workspace.Baseplate.CFrame *= CFrame.Angles(math.rad(4),math.rad(r.Y),math.rad(5))
1 Like

Then simply do:

part1.Orientation.Y = CFrame

If you want to add

part1.Orientation.Y += CFrame

Ty I’ll try this out when I get the chance and mark u as a solution if it works.

Thats not how that works.

the issue with using *= is its constantly adding to the rotation rather than setting it. How can I set it? I’m trying to constantly set the rotation in a loop.

You just do BasePart.CFrame = CFrame instead of Multilying it, However if you want to add on to the new CFrame, you have to Multiply it.

I misunderstood sorry :sweat_smile

I might be dumb here, but wouldn’t multiplying the value make it go like:
1-2-4-8-16-32-64-128-256-512…
Like a similar pattern, shouldn’t you add?

it’s not multiplying the correct operator for adding two cframes is * / *=

Why isn’t it +/+=?
I don’t understand

To get a CFrame rotated relative to the HumanoidRootPart current orientation, here is the method I use. You can also use CFrame.Angles, but unless the character is standing upright, you will have to convert CFrame.Angles to object space I believe.

local rotationStep = 0.1 -- 9 degree, maximum is 1 that totals 90 degree. To rotate other way, change `+` sign to `-` before the `RightVector`.
local root = character.HumanoidRootPart -- or whatever else you are rotating.

while true do
	
	root.CFrame = CFrame.lookAt(root.Position,(root.Position +  root.CFrame.LookVector):Lerp(root.Position + root.CFrame.RightVector,rotationStep))
	
	task.wait(1)
	
end