Tweening Part Glitches Back

Hello, I’ve got a Tweenglitch that I’m trying to fix.
Video:


Code:

local TweenService = game:GetService('TweenService')
local Top = script.Parent.Top
local Bottom = script.Parent.Bottom

local tweenInfo = TweenInfo.new(
	10, -- slow for demonstration
	Enum.EasingStyle.Linear,  
	Enum.EasingDirection.Out,  
	1, 
	false, 
	0 
)

local TopGoal = {}
TopGoal.Position = Vector3.new(Top.Middle.Position.X, Top.Middle.Position.Y - 15,Top.Middle.Position.Z)
TopGoal.Orientation = Vector3.new(Top.Middle.Orientation.X, Top.Middle.Orientation.Y + 180, Top.Middle.Orientation.Z)

local TopEnd = {}
TopEnd.Position = Vector3.new(Top.Middle.Position.X, Top.Middle.Position.Y,Top.Middle.Position.Z)
TopEnd.Orientation = Vector3.new(Top.Middle.Orientation.X, Top.Middle.Orientation.Y, Top.Middle.Orientation.Z)

local BottomGoal = {}
BottomGoal.Position = Vector3.new(Bottom.Position.X, Top)

local tween = TweenService:Create(Top.Middle, tweenInfo, TopGoal)
local tween2 = TweenService:Create(Top.Middle, tweenInfo, TopEnd)
wait(3)
tween:Play()


tween.Completed:Connect(function()
	tween2:Play()
	print('Ok Tween 2 Playing')
end)

tween2.Completed:Connect(function()
	tween:Play()
	p

So what I want it to do is move down the goal position, then play the second tween that reverts it back.to the original position.
The rotation basically performs a 360.

I can provide more information.

Thanks for any help!

1 Like

Try this: instead of having a 2nd tween to move it back to the original spot just set it to reverse, with a delay of your choice.


local tweenInfo = TweenInfo.new(
	10, -- slow for demonstration
	Enum.EasingStyle.Linear,  
	Enum.EasingDirection.Out,  
	1, 
	true, 
	0  --delay you want
)
2 Likes

If you want it to reverse turn then you don’t really have to make a whole other tween for it, you can just allow reverse in TweenInfo like @reetism said, also I highly suggest using CFrames.

1 Like

You made the repeatCount 1; it’s supposed to be 0 if you don’t want it to loop through it once.

So the tween info would be:

local tweenInfo = TweenInfo.new(
	10, -- slow for demonstration
	Enum.EasingStyle.Linear,  
	Enum.EasingDirection.Out,  
	0, -- repeat count 
	false, 
	0 
)

Literally only the Time and EasingStyle aren’t default so to make your script shorter make it:

local tweenInfo = TweenInfo.new(
	10, -- slow for demonstration
	Enum.EasingStyle.Linear,  
)

And to undo the tween; so it goes back the way it cames from you’d need to make the tweenInfo the following:

local tweenInfo = TweenInfo.new(
	10, -- slow for demonstration
	Enum.EasingStyle.Linear,  
	Enum.EasingDirection.Out,  
	0, 
	true, -- reverse bool
)

Note, this won’t make it rotate the same way but will just reverse it the way it came.

1 Like