Tween loop isn't seamless

I’m trying to make a fan spin, so I used a tween to make it spin 360 degrees. The problem is, everytime it makes a full rotation, it loops, but not seamlessly. You can easily see it restart. Whats the fix, or workaround for this?

Video:

Code:

local TweenService = game:GetService("TweenService")

local part = script.Parent

local tweenInfo = TweenInfo.new(
	5, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	false, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)

-- create two conflicting tweens (both trying to animate part.Position)
local tween1 = TweenService:Create(part, tweenInfo, {Rotation = Vector3.new(0, 360, 0)})

-- listen for their completion status
tween1.Completed:Connect(function(playbackState)
end)

-- try to play them both
tween1:Play()
2 Likes

Things will get messy when you use TweenService for continuous rotations.

Which way should it turn, for example, is unspecified.

You could break it up into three 120 degree rotations, but that’s a weird solution.

Is there any reason you can’t just spin it without TweenService?

local part = script.Parent
local speed = 60 -- degrees/second

local angle = 0
game:GetService("RunService").Stepped:Connect(function(t, dt)
	angle += dt * speed
	part.Rotation = Vector3.new(0, angle, 0)
end)
3 Likes

Yea, I figured TweenService would be fine for a spinning object but obviously not. This is a better alternative instead, thanks lol.

1 Like