How to rotate a model smoothly using CFrame

I want to have a cylinder rotate smoothly using CFrame.

I have tried to set the model’s primary part’s CFrame which achieves the rotation that I want but it isn’t smooth when played in game.

I don’t know very much about scripting so this is about how far I got.

while true do
	script.Parent:SetPrimaryPartCFrame(script.Parent.Center.CFrame * CFrame.fromEulerAnglesXYZ(45,0,0))
	wait(0.2)
end

This is what I have for the script.

1 Like

Try this


local part= script.Parent
local Run = game:GetService("RunService")

Run.Hearbeat:Connect(function()
    part.Orientation = part.Orientation +Vector3.new(0, 1, 0) -- adjust the values to your preferances
end)

Hope that helped,
Theyoloman1920

fromEulerAnglesXYZ is in radians. Meaning to get a 45 degree angle turn you should use math.pi / 2 or math.rad(45).

You can make it smoother by using a smaller number, for example:

	script.Parent:SetPrimaryPartCFrame(script.Parent.Center.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(1),0,0)) -- turns by 1 degree
3 Likes

Why would he use CFrame? I know that this is what he needs, but there is no difference between Orientation and CFram.Angles

Thank you.

This is exactly what I wanted/needed.