How to use CFrame?

Hello, I’m trying to use CFrame to move a part 1 stud to its “front” rather than on the XYZ axis.

For example if the front of the part is facing the X but if you turn the object the front would be facing the Z axis

Based on that how would I move the part towards its “front?”

Part:PivotTo(Part:GetPivot() * CFrame.Angles(0,math.rad(90),0))

Here’s some cool documentation

If you would want to rotate a part always to left relative to it’s front then you could try this

local part = script.Parent

local rotatedCFrame = CFrame.Angles(0, math.rad(90), 0)
part.CFrame = part.CFrame:ToWorldSpace(rotatedCFrame)

You can use something called lookvector. It’s a vector 3 that’s points in the direction of the front of the block.

Yes, I solved the issue on my own and it involved LookVector.

Here’s how it works

  • LookVector - Front of object
  • RightVector - Right of object
  • UpVector - Top of the object.

They do not offer a DownVector, LeftVector, Or a BackVector because you can create those with the ones they already gave you. For example:

  • BackVector - Just do a negative LookVector
  • LeftVector - Just do negative RightVector
  • DownVector - Just do negative UpVector.

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