How to make a part rotate 90 degrees smoothly

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
	self.gyro.CFrame = self.gyro.CFrame * CFrame.Angles(0, 0, math.pi / 100)

Thanks in advance to anybody who replies :slightly_smiling_face:

Use lerp:

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)

You can use TweenService!
It tweens any specificed properties of an object over time automatically and makes it look smooth!

TweenService (

1 Like
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local Goal = {}
Goal.CFrame = Part.CFrame * CFrame.Angle(0, math.rad(90), 0)

TweenService:Create(Part,, Goal):Play()

Goal is the end result, TweenInfo is how many seconds it takes to get to the end Result, and the Part is the object it effects.


I recommend checking out this article on the Roblox developer hub teaching you how to make a spinning platform/part with no scripts:

1 Like