There are plenty of free-modeled rotate tools you can take a look at and see how you can implement one of these systems.
The first parameter of the MouseDrag event is the axis that the player dragged their mouse on. The second one is just the RelativeAngle (which has no wiki documentation so I don’t know what it is) so you can just use if statements and detect which axis they dragged on and then you can perform CFrame operations on them using basic math.
I created a quick prototype in studio to test this system out and it works pretty neat. (It’s in a local script in StarterGui, this is just a demonstration, it won’t work in FilteringEnabled)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local increment = 5
local lastCFrame = nil
function round(number)
return math.floor((number / increment) + 0.5) * increment
end
function AngleFromAxis(axis, r)
local relativeAngle = math.rad(round(math.deg(r)))
return axis == Enum.Axis.X and {relativeAngle, 0, 0}
or axis == Enum.Axis.Y and {0, relativeAngle, 0}
or axis == Enum.Axis.Z and {0, 0, relativeAngle}
end
script.Parent.ArcHandles.MouseDrag:Connect(function(axis, relativeAngle, delta)
workspace.Part.CFrame = lastCFrame * CFrame.Angles(unpack(AngleFromAxis(axis, relativeAngle)))
end)
script.Parent.ArcHandles.MouseButton1Down:Connect(function()
lastCFrame = workspace.Part.CFrame
end)
@AdvancedDrone I had a feeling you had to use something like lastCframe, anyway it works 10x better. But increment still does not work correctly, did it work for you?
A proposal to increment is to use a delta and compare it against your increment.
Your delta would be the CFrame minus last CFrame then by getting the absolute value of that and comparing if its greater than or equal to the increment.