Tween glitches after a few loops

I have a fairly simple tween running on an object that I want to loop. It gets slowly bigger, waits a bit, then gets slowly smaller and repeats.
For some reason, after a loop or two, when it gets to the bigger size the object returns to the original size during the waiting period before returning to the size it should be and running the shrinking tween. I feel like I’d know the issue if it did this every time, but it doesn’t, it takes a few loops so I am confusion

Here’s the script I use, no clue what to do lmao

local TS = game:GetService("TweenService")


local sphere = script.Parent



	local pos1 = {["Size"]=sphere.Size}
	local pos2 = {["Size"]=sphere.Size + Vector3.new(4,0,0)}



	local intweeninfo = TweenInfo.new(4,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
	local outtweeninfo = TweenInfo.new(6,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)


	local tweenopen = TS:Create(sphere,intweeninfo,pos2)
	local tweenclose = TS:Create(sphere,outtweeninfo,pos1)




	while true do
		tweenopen:Play()
		tweenopen.Completed:Wait(.1)
		wait(3)
		tweenclose:Play()
		tweenclose.Completed:Wait(.1)
	end

Can you show a video of the tween?

From what I can see, it seems like you are not resetting the initial size of the sphere back to its original size after playing the shrinking tween. This may cause the tween to be “stacked” on top of the previous one, making it appear not to work correctly after a few loops. To fix this, you can add pos1 just before playing the shrinking tween tweenclose:Play() to set the sphere’s size back to its original size, like this:

while true do
    tweenopen:Play()
    tweenopen.Completed:Wait(.1)
    wait(3)
    tweenclose:Play()
    sphere.Size = pos1["Size"] -- reset sphere's size back to its original size
    tweenclose.Completed:Wait(.1)
end

This should reset the sphere size and allow the tween to loop correctly without any issues.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.