I'm making a gui that will go up and down but the second Tween is not working the problem is at the comment --here is the problem
local object = script.Parent.Parent.Frame object.AnchorPoint = Vector2.new(0.023, 0.593) object.Position = UDim2.new(0.023, 0, 0.638, 0) local button = script.Parent local Open = false local Text = script.Parent.Parent.TextLabel Text.AnchorPoint = Vector2.new(0.023, 0.593) Text.Position = UDim2.new(0.024, 0, 0.64, 0) --------------------------------------------------------------- button.MouseEnter:Connect(function(x, y) object:TweenSize( UDim2.new(0, 9, 0, 46), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.3, true ) end) button.MouseLeave:Connect(function(x, y) object:TweenSize( UDim2.new(0, 4, 0, 46), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.3, true ) end) ---------------------------------------------------------------- --here is the problem function leftMouseButtonUp(x, y) if Open == false then Open = true Text.BackgroundColor3 = Color3.new(0.356863, 1, 0.0823529) Text:TweenPosition( UDim2.new(0.024, 0, 0.63, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.2, false ) wait(0.1) Text.BackgroundColor3 = Color3.new(0.356863, 1, 0.0823529) Text:TweenPosition( UDim2.new(0.024, 0, 0.64, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.2, false ) else print("hi") end end script.Parent.MouseButton1Up:Connect(leftMouseButtonUp)
Hello!
You see, the function TweenPosition
requires 5 arguments, which are correctly filled in your script. The fifth argument, asks whether to not work if a tween is already happening. In your case, it is set to false
, so, just as you specifically told it to, it won't do anything.
The fix is simple: Increase the wait, decrease the duration, or just set that fifth argument to true.
--You can either: Text:TweenPosition( UDim2.new(0.024, 0, 0.63, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.2, --1. decrease the duration false ) wait(0.1) --2. increase the wait Text.BackgroundColor3 = Color3.new(0.356863, 1, 0.0823529) Text:TweenPosition( UDim2.new(0.024, 0, 0.64, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.2, false --or 3. set this to true )
I hope this helped. If you're still confused, you can check the developer reference here, or, alternatively, you can ask questions below.