Math.rad(180) not rotating part 180 degrees?

I am trying to rotate a part exactly 180 degrees with CFrame (math.rad(180)) and its rotating 179.75 degrees instead!

Try and add .25 to the 180. :thinking:

CFrame.new(math.rad(180.25), 0, 0)

Nope, that made it worse. But thanks anyways!

Use CFrame.Angles

CFrame.Angles(math.rad(180), 0, 0)
1 Like

Thats what I did but i am changing on the Z axis

to keep the position:

CFrame.new(Part.Position) * CFrame.Angles(math.rad(180),0,0)

CFrame.Angles has 3 parameters X, Y, Z

CFrame.new(Part.Position) * CFrame.Angles(0,0,math.rad(180))

edit:

I don’t saw the question, but you can floor it to make sure its 180

CFrame.new(Part.Position) * CFrame.Angles(0,0,math.rad(math.floor(180)))

This is what I use to cframe rotate

local model = game.Workspace.Model

model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() * CFrame.Angles(0, 0, math.rad(180)))

This is what the line of code looks like:
x.CFrame = CFrame.new(x.Position + Vector3.new(0, ((self:GetExtentsSize().Y/2)-.5), 0)) * CFrame.Angles(0, math.rad(math.floor(180)), 0)

Ignore the Vector3 part

there is no way, that math.rad(180) is 179.75, make sure to test it in studio with command bar, and check parts rotation after that

you can also do

CFrame.Angles(0,math.rad(180 + 0.25), 0)

Maybe try math.rad(0, 0 (180)?
I’m new to scripting and I also don’t understand what axis you want it on so I’ll put it on the Z.
I’m sorry if this is an absolutely stupid answer but well that’s my only one.

Just try testing it out with a different axis until it works.

It probably won’t work, but try pi since math.rad(180) is pi:

CFrame.Angles(math.pi,0,0)

I found the problem, it wasn’t actually a problem with the rotation. I am making a tower of hell game and my tower piece was wierd so it made the thing bug. But thank you all for your help! :slight_smile: