Ok so I can rotate this model freely with arrow keys but I wrote up the returning to original fixture script and sometimes it goes to the right place other times it's tilted or in the wrong position/caught in an infinite loop.
How do I fix this?
local desiredrestrotation = Vector3.new(0, 65, 0) --Position it should fix to (note this is rotation not position) local running = false function returnoriginalfix() if up == false and down == false and right == false and left == false and running == false then running = true local x = false local y = false local z = false --Fix Y axis spawn(function() repeat wait() if math.floor(controlbrick.Rotation.Y) > desiredrestrotation.Y then db:SetPrimaryPartCFrame(controlbrick.CFrame * CFrame.Angles(0, math.rad(-.5), 0)) else db:SetPrimaryPartCFrame(controlbrick.CFrame * CFrame.Angles(0, math.rad(.5), 0)) end y = true until math.floor(controlbrick.Rotation.Y) == desiredrestrotation.Y end) --Fix X axis spawn(function() repeat wait() if math.floor(controlbrick.Rotation.X) > desiredrestrotation.X then db:SetPrimaryPartCFrame(controlbrick.CFrame * CFrame.Angles(math.rad(-.5), 0, 0)) else db:SetPrimaryPartCFrame(controlbrick.CFrame * CFrame.Angles(math.rad(.5), 0, 0)) end until math.floor(controlbrick.Rotation.X) == desiredrestrotation.X x = true end) --Fix Z axis spawn(function() repeat wait() if math.floor(controlbrick.Rotation.Z) > desiredrestrotation.Z then db:SetPrimaryPartCFrame(controlbrick.CFrame * CFrame.Angles(0, 0, math.rad(-.5))) else db:SetPrimaryPartCFrame(controlbrick.CFrame * CFrame.Angles(0, 0, math.rad(.5))) end until math.floor(controlbrick.Rotation.Z) == desiredrestrotation.Z z = true end) --check for fixed orientation repeat wait() until x == true and y == true and z == true x = false y = false z = false running = false end end