:PivotTo() Automatically rotates the model to one direction

This is a simple model

When I try move the model I use :PivotTio().
Example:selectedPiece:PivotTo(CFrame.new(xValue, 1.5, xValue))
It changes the position (as it should), but it also automically rotates the piece to a certain set direction.

Result is them all flipping this side. When the Model is already facing that way it’s no issue, but most of the Models aren’t.

Is there any way to keep the original direction when using :PivotTo()?

Try including the rotation information with the CFrame.

local pivot = selectedPiece:GetPivot()
selectedPiece:PivotTo(CFrame.new(Vector3.new(xValue, 1.5, xValue)) * (pivot - pivot.Position))
2 Likes

Pff, that works! Using GetPivot somewhere did arise in my head, but doing it like this… never thought to do it like this, even though it does make sense. Thanks :happy3:

1 Like

Might be a bump, unsure.

Instead of doing an expression (Pivot - Pivot.Position), you can do Pivot.Rotation, as it is identical.

(the original just removes the position aspect of the CFrame, which equals to the Rotation.)

1 Like

Ah, that’s even easier. Thanks for adding!

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