Help With Smooth Tween

Hey, thanks for reading this topic. My issue is that I wanted to replicate an animation with tween-service but it did not give the expected results. So I am wondering if anyone could help me with this animation.

My code:

local TweenService = game:GetService("TweenService")

local big = script.Parent.BigCube
local small = script.Parent.SmallCube

--local TweenValue1: CFrameValue = big.TweenValue
--TweenValue1.Value = big:GetPivot()

--local TweenValue2: CFrameValue = small.TweenValue
--TweenValue2.Value = small:GetPivot()

local test = TweenInfo.new(
	3, -- 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)
	-3 -- DelayTime
)

--local test2 = TweenInfo.new(
--	1.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)
--	-3 -- DelayTime
--)

local tween1 = TweenService:Create(big.BottomLeftFront, test, { Position = big.BottomLeftBack.Position })
local tween2 = TweenService:Create(big.BottomRightFront, test, { Position = big.BottomRightBack.Position })
local tween3 = TweenService:Create(big.TopLeftFront, test, { Position = big.TopLeftBack.Position })
local tween4 = TweenService:Create(big.TopRightFront, test, { Position = big.TopRightBack.Position })
local tween5 = TweenService:Create(small.BottomLeftFront, test, { Position = big.BottomLeftFront.Position })
local tween6 = TweenService:Create(small.BottomRightFront, test, { Position = big.BottomRightFront.Position })
local tween7 = TweenService:Create(small.TopLeftFront, test, { Position = big.TopLeftFront.Position })
local tween8 = TweenService:Create(small.TopRightFront, test, { Position = big.TopRightFront.Position })

local tween9 = TweenService:Create(big.BottomLeftBack, test, { Position = small.BottomLeftBack.Position })
local tween10 = TweenService:Create(big.BottomRightBack, test, { Position = small.BottomRightBack.Position })
local tween11 = TweenService:Create(big.TopLeftBack, test, { Position = small.TopLeftBack.Position })
local tween12 = TweenService:Create(big.TopRightBack, test, { Position = small.TopRightBack.Position })
local tween13 = TweenService:Create(small.BottomLeftBack, test, { Position = small.BottomLeftFront.Position })
local tween14 = TweenService:Create(small.BottomRightBack, test, { Position = small.BottomRightFront.Position })
local tween15 = TweenService:Create(small.TopLeftBack, test, { Position = small.TopLeftFront.Position })
local tween16 = TweenService:Create(small.TopRightBack, test, { Position = small.TopRightFront.Position })

--local tween17 = TweenService:Create(big, test2, {CFrame = big.CFrame * CFrame.Angles(0, 0, math.pi/2)})
--local tween18 = TweenService:Create(small, test2, {CFrame = small.CFrame * CFrame.Angles(0, 0, math.pi/2)})

--local tween17 = TweenService:Create(TweenValue1, test, {Value = big:GetPivot()*CFrame.Angles(0, math.pi/2, 0)})
--local tween18 = TweenService:Create(TweenValue2, test, {Value = small:GetPivot()*CFrame.Angles(0, math.pi/2, 0)})

--TweenValue1.Changed:Connect(function()
--    big:PivotTo(TweenValue1.Value)
--end)

--TweenValue2.Changed:Connect(function()
--    small:PivotTo(TweenValue2.Value)
--end)

tween1:Play()
tween2:Play()
tween3:Play()
tween4:Play()
tween5:Play()
tween6:Play()
tween7:Play()
tween8:Play()

tween9:Play()
tween10:Play()
tween11:Play()
tween12:Play()
tween13:Play()
tween14:Play()
tween15:Play()
tween16:Play()

--tween17:Play()
--tween18:Play()

The model file:
tesseract.rbxm (6.5 KB)

I’m very sorry for the bad code, it was heavily heavily rushed.

What I expected:
1231231

What I got:
https://i.gyazo.com/6a119de3493f8021f38afb0adb31fe78.gif
6a119de3493f8021f38afb0adb31fe78

https://i.gyazo.com/46e07283fc30bd3d751dc5446f58f068.gif
46e07283fc30bd3d751dc5446f58f068

If you look very closely, you can see that in my animation there is a tiny pause at the end of the animation before it repeats, which is not smooth like the animation I wanted to replicate.

Please feel free to let me know if you need any additional info.

2 Likes

I believe it’s because you set the delay time to -3. Try setting the delay time of the tween to 0, although I’m not actually sure if this would work.

Hey, thanks for the response, I changed the delay time to 0 but nothing changed sadly. :frowning:

1 Like

You can try messing with the EasingStyle and EasingDirection, but if that doesn’t fix the issue, then it might be something to do with the positions of the parts you are trying to tween.
Also, I noticed that some of your code lines are commented. Was this intentional, and do they also play a significant role in how your animation looks?

1 Like

thank you for script i was looking for

2 Likes

I’ve tried messing with the easingstyle and direction but they didn’t really do anything positive. The position of the parts is just the position of the other attachments. The commented code is just for testing purposes, they don’t do anything.