Responsive UI Debounce

I am currently making UI for my game, I am using tweening in my UI to make it look interesting, I am wondering how you would add a good Debounce so that I can open and close my script and make it feel good to open and close.

Some UI Debounce that I think looks good is from Sword Fighting, When you open and close it if you do it fast the tweening doesn’t even finish it just goes back and it also doesn’t glitch out.

I have tried a bool Variable but I find it is sometimes unresponsive

So you objective is to basically open and close the UI smoothly?

Yes basicly, I know how to use tweening witch makes it look good, But the only way i know how to open and close it is with a bool variable witch makes it sometimes unresponsive. here is some code that shows what i mean

hopButton.MouseButton1Up:Connect(function()
if(shopActive == false) then
shop:TweenPosition(UDim2.new(0.15, 0, 0.15, 0), “Out”, “Quad”, 1, false)
shopActive = true
elseif(shopActive == true) then
shop:TweenPosition(UDim2.new(0.15, 0, -0.8, 0), “Out”, “Quad”, 1, false)
shopActive = false
end
end)

Check out the override parameter to TweenPosition: GuiObject | Documentation - Roblox Creator Hub

You probably want to pass true instead of false, so that you can interrupt an animation if another animation is suddenly more relevant.

1 Like

Ok thankyou, Would you mind showing me an example of how to use it?

1 Like
shop:TweenPosition(UDim2.new(0.15, 0, -0.8, 0), “Out”, “Quad”, 1, true) -- change this to true not false

oh ok, where would I put the tween to put it away then

Well all you do is change the last part of :TweenPosition() from false to true.

Heres what your updated script would be:

hopButton.MouseButton1Up:Connect(function()
    if(shopActive == false) then
        shop:TweenPosition(UDim2.new(0.15, 0, 0.15, 0), “Out”, “Quad”, 1, false)
        shopActive = true
    elseif(shopActive == true) then
        shop:TweenPosition(UDim2.new(0.15, 0, -0.8, 0), “Out”, “Quad”, 1, false)
        shopActive = false
    end
end)

oh ok, so all should keep the shopActive variable then

Thankyou so much you were a lot of help

1 Like