CFrame.Angles issue

Hey guys! I’ve encountered an issue. No matter what I try, I can’t make this Axe model spin constantly! The model itself moves with no issue, but it won’t spin at all. It only switches to a random orientation, and it stays that way permanently. I’ve tried everything I know regarding CFrame, but I’m not that smart when it comes to them, so if you know how I can make this work, please let me know. I’ll greatly appreciate it. :innocent:

Axe:PivotTo(CFrame.new(Axe.PrimaryPart.Position+Vector3.new(0, 0, -1)) * CFrame.fromEulerAngles(0, Axe.PrimaryPart.CFrame.Y - math.rad(2), 0))

Heyo, it looks like you might have made a mistake in your calculations.

Axe:PivotTo(CFrame.new(Axe.PrimaryPart.Position+Vector3.new(0, 0, -1)) * CFrame.fromEulerAngles(0, Axe.PrimaryPart.CFrame.Y - math.rad(2), 0))

When you are calculating the new CFrame for the Angles of your model, you use this snippet:

CFrame.fromEulerAngles(0, Axe.PrimaryPart.CFrame.Y - math.rad(2), 0))

The issue with this is that you base the rotation off of the part’s CFrame on the y-axis. In this case, CFrame.Y only refers to the position of the model, on the Y-axis, which in your case never changes.

Instead you can get the CFrame’s Y-axis rotation by doing the following:

local _,yRot,_ = Axe.PrimaryPart.CFrame:ToEulerAngles()

Which leaves you with the following code:

local _,yRot,_ = Axe.PrimaryPart.CFrame:ToEulerAngles()
Axe:PivotTo(CFrame.new(Axe.PrimaryPart.Position+Vector3.new(0, 0, -1)) * CFrame.fromEulerAngles(0, yRot - math.rad(2), 0))

Hope this helps!

This worked for only a few seconds. It stopped once it hit 90 degrees. :frowning_face:

1 Like

Put this inside of the loop. It works now. But thank you for your time and trying to help me anyway. :slight_smile:

Angles -= 1
Axe:PivotTo(CFrame.new(Axe.PrimaryPart.Position+Vector3.new(0, 0, -1)) * CFrame.Angles(0, math.rad(Angles), 0))

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