I have two parts that are welded together. One is named PivotPart, and the other is named Flag. The flag pivots around the PivotPart, and it's told to point towards a certain orientation. So how do I make the flag point towards whatever WindDegree is by "CFraming from the weld"?
I'm terrible with CFrames, absolutely terrible. I don't understand them that well and all explanations that I can possibly find are confusing. I understand that they are positions and rotations, and the fact that they use matrices. I can't find anything to help me with this.
What I've tried:
ship = script.Parent WindDegree = 45 ship.PivotPart.Weld.C0 = ship.PivotPart.Weld.C1 * CFrame.fromEulerAnglesYXZ(0,WindDegree,0)
This is because CFrame needs RADIANS. To convert 45 degrees to radians, we can do
math.pi / 4
or
math.rad(45)
or
45 * 0.0174533 --stole off google
To fix this, your code would be
local ship = script.Parent --local variables are quicker to access local WindDegree = math.rad(45) ship.PivotPart.Weld.C0 = ship.PivotPart.Weld.C1 * CFrame.fromEulerAnglesYXZ(0,WindDegree,0)
Hope this helps!