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

how to tween gui without finishing previous tween?

Asked by 3 years ago

I have a gui and I want to tween it to move up and down on the screen after I press a button.

I did TweenService:TweenPosition and if I spam the button, it will finish current and stop working. How would I make it so if I press it again, it will go back up/down even if it didn't finish the last tween?

-- example of my script (not exact bc I don't have it in front of me rn and cant get on)
-- I used a debounce to make it so they couldnt spam but I didn't like waiting for the debounce to close it.

local idk = true
script.Parent.MouseButton1Click:Connect(function()
    if idk then
        idk = false
        tweenOut()
    else
        idk = true
        tweenIn()
    end
end)

function tweenIn()
    -- basically same as tweenout 0:
end

function tweenOut()
    script.Parent:TweenPosition(Udim2.new(0,0,0,0), Stuff here)
end

1 answer

Log in to vote
1
Answered by 3 years ago

You have to pass the fifth parameter to override all in-progress tweens.

Ad

Answer this question