So, in a script I'm making I want a part to have a constant rotation of (0, 0, 0). Unfortunately, I don't know how to change the rotation of an object through script. The current script I have is this:
function changed(Rotation) if script.Parent.CFrame ~= script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,0) then -- if rotation is not (0, 0, 0) then script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,0) -- make rotation (0, 0, 0) end end script.Parent.Changed:connect(changed) -- script.Parent is a part
So, I need a statement that will correctly change an object's rotation through script, without the math.pi mumbo jumbo (unless that's the only way to do it).
The easiest way to make an object have no rotation is to use this nifty like hack:
script.Parent.CFrame = CFrame.new(script.Parent.Position)
Your if
statement is always true, by the way, because CFrame.Angles()
applies a Rotation, it doesn't set the Rotation. In order to actually get the current Rotation of a part, you're going to have to look at its Rotation Vector3, or do math to the results of The components
method of CFrame.