I have been working on a part dragging system recently and I wanted to make it so when you press “R” the part will rotate 90 degrees. I’ve close, but the part rotates slightly over 90 degrees.
I’m using body gyros to rotate the part
Here’s my code:
for i = 0, 1 / 3 * 10, .05 do
RunService.RenderStepped:Wait()
self.gyro.CFrame = self.gyro.CFrame * CFrame.Angles(0, 0, math.pi / 100)
end
local rotation = CFrame.Angles(0, math.rad(90), 0)
local function rotate(part)
local targetCFrame = part.CFrame * rotation
for i = 0, 1, .1 do
part.CFrame = part.CFrame:Lerp(targetCFrame, i)
RunService.RenderStepped:Wait()
end
end