Issues with tween position

Hey! I’ve been having some problems with tweening GUI’s and I was wondering if anyone else had a similar issue. In a game that I’m working on, we have an audio visualizer. I added in a close and open button for it and used InOut and Back for the tweening of the closing/opening animation. When I tested this out, I found that the GUI was tweening, but it a very peculiar way.

Here is what I mean:

In this video, you can see that I press the button to close and open it. In the middle of the tween, you can see that it kind of glitches back and continues the tween. I’ve tried other tween styles and directions and they seem to work fine. I doubt this is a Roblox bug but if anyone has help or feedback they could offer me, I would really appreciate it!

Here is the open/close button’s code (extremely simple):

-- Variables -- 

local Main = script.Parent.Parent.Main
local Control = script.Parent
local Open = true

-- Scripts --

Control.MouseButton1Click:Connect(function()
	if Open == true then -- close
		Main:TweenPosition(UDim2.new(1, 0,0.68, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Back)
		Control:TweenPosition(UDim2.new(0.98, 0,0.754, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Back)
		Control.Text = "<"
		Open = false
	else -- open
		Main:TweenPosition(UDim2.new(0.755, 0,0.68, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Back)
		Control:TweenPosition(UDim2.new(0.73, 0,0.754, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Back)
		Control.Text = ">"
		Open = true
	end
end)

Here’s how it’s setup:
Image

1 Like

Make sure all the numbers are spaced out.

The spacing in the numbers doesn’t matter, there are already commas there.

Okay, now I know what it is. Your Open = true should be at the top of

Main:TweenPosition(UDim2.new(0.755, 0,0.68, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Back)
instead of at the end.

And, if that didn’t work then the if Open == true then is the problem.

That isn’t the issue either. The GUI opens and closes, but there is a problem with the tweening. So the variable has nothing to do with it.

I think this is a bug. Try using ‘In’ or ‘Out’ rather than ‘InOut’.

Okay, I don’t know what it is then. I am telling you it has to do something with your true\false statements.

The script opens and closes the GUI fine, and the logic adds up to make it function correctly. The problem may lie within the tween service.

Not too sure of what’s the issue here, but using TweenService:Create() is more stable than TweenPosition from what I experienced. I’d recommend you to use TweenService:Create() and see if the results change, and make the “open = true/false” before “then/else”.

2 Likes