I’m currently trying to learn how to use CFranes, but I’m still not able to understand how a CFrame’s orientation works.
I already know how to use CFrames to make a part match another part’s position:
while wait() do
part1.CFrame = CFrame.new(part0.CFrame.X, part0.CFrame.Y, part0.CFrame.Z)
end
Now I want to do the same thing, but with orientation instead of position. I need to get a CFrame angle’s X, Y and Z numbers and I don’t know how to do that.
I would like to do something similar to this:
while wait() do
part1.CFrame = CFrame.Angles(part0.CFrame.Orientation.X, part0.CFrame.Orientation.Y, part0.CFrame.Orientation.Z)
end
A CFrame stores a position and a 3x3 rotation matrix. You can get the rotational component of a CFrame in a couple different ways, either CFrame:GetComponents() which will give you the position and the 3x3 matrix or CFrame:ToEulerAnglesXYZ() which will give you the rotation in the form of euler angles. You can reconstruct the CFrame using EulerAngles with the CFrame.Angles constructor or simply use CFrame.new with what CFrame:GetComponents() gives you.