Creating smooth rotation of model

Simply trying to a get to rotate smoothly without it jittering

local Model = workspace:WaitForChild('Rotating')

while wait() do
	for i = 1, 360 do
		Model:SetPrimaryPartCFrame(Model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(i), 0))
		wait(0.5)
	end
end
wait(0.5)

that one piece is why it looks jittery I suggest decreasing the time to like .1 or .2

2 Likes

I would suggest using RunService to yield. RunService.Stepped:Wait() yields 1/60th of a second. Wait() only yields 1/30th of a second.

Creating a new CFrame prevents ā€œCFrame.Angles(0, math.rad(i), 0)ā€ from changing the models base position.

local RunService = game:GetService("RunService")
local Model = workspace:WaitForChild('Rotating')

while wait() do
	for i = 1, 360 do
		Model:SetPrimaryPartCFrame(CFrame.new(Model.PrimaryPart.Position) * CFrame.Angles(0, math.rad(i), 0))
		RunService.Stepped:Wait()
	end
end

Another way to make it smoother would be to do the smoothing on the client and the server would just rotate without smoothing.

6 Likes

Iā€™m agree with that gud idea below post better gom with that

you can always use the tween service that way you can adjust the speed and other effects of the tween,
here is a post on tweening models it involves using weld constraints but it will give you a nice smooth effect:

The problem here is that with varying frames per second on the clientā€™s computer (if you run this on the client), the wait would yield different times so it would be useful to put an if statement using tick() as a wait so it makes the rotation speed precise. For instance, you can experiment with this with an fps unlocker or a ā€˜lag makerā€™ script in your game.