Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

TweenPosition wait(0.1) TweenPosition not working?

Asked by 2 years ago

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)

1 answer

Log in to vote
0
Answered by
RAFA1608 543 Moderation Voter
2 years ago
Edited 2 years ago

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.

Ad

Answer this question