Set CFrame except for one side?

I want to set something’s CFrame to be exactly like another thing’s except I don’t want it to be rotated on the X axis at all. I want to keep the position on the X axis, but not the rotation. How would I do this?

This is what I’m doing right now, but it moves the part above where it should be:

cl:SetPrimaryPartCFrame(target.CFrame)
cl.Part.Orientation = Vector3.new(0, cl.Part.Orientation.Y, cl.Part.Orientation.Z)
1 Like

This is one of the times the evil Safe Move rears its ugly head. It’s a really awful and unintuitive behavior that causes parts to shift up whenever certain properties are set (e.g. Position, Orientation, Shape, etc). There were plans to remove it, but it seems like it’s being held up by legacy games:

and since there’s a big game (Bloxburg) that uses safe move, that’s probably preventing it from being nuked.

For now you’ll need to use purely CFrame to avoid safe move. You can change your code to:

local orientation = CFrame.Angles(0, cl.Part.Orientation.Y, cl.Part.Orientation.Z)
cl:SetPrimaryPartCFrame(CFrame.new(target.CFrame.p) * orientation)
4 Likes

Yeah I knew about that, I was really hoping they’d removed it by now. I’ll try that, thanks.

1 Like

They could just remove the safe move and to not break old games, make it a checkbox which is enabled by default.

1 Like

1 Like