Rotating using lerp

I am trying to rotate a part using the :Lerp() function. It only rotates when I move the part aswell, if I only tell it to rotate it either teleports far away or just vanishes.

for i = 0, 1, 0.05 do
	wait()
	script.Parent.CFrame = script.Parent.CFrame:Lerp(CFrame.Angles(0, math.rad(90), 0), i)
end

For this script the part moves to the origin.

Nevermind, I found that this works:

local Part = script.Parent
local Target = Part.CFrame * CFrame.Angles(0, math.rad(90), 0)

for i = 0, 1, 0.01 do
	Part.CFrame = Part.CFrame:Lerp(Target, i)
	wait()
end
2 Likes