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

How do I fix this GUI Animation so it continues from where it's interrupting?

Asked by
Lualaxy 78
5 years ago

So I am trying to make a GUI animation when hovered over it does the "TweenSize" thing and it works. But if the mouse leaves the frame before the first Tween Size is not over yet it doesn't stop and go back but it just completes the TweenSize from before and breaks.

This is how it breaks: https://gyazo.com/fabbf187ca92588e207efdbdecafdd4b

So what I did is I made 2 scripts. One is for opening: Code:

script.Parent.MouseEnter:Connect(function()
script.Parent:TweenSize(UDim2.new(0, 216, 0, 216))
end)

and the other script is for closing: Code:

script.Parent.MouseLeave:Connect(function()
script.Parent:TweenSize(UDim2.new(0, 60, 0, 216))
end)

So what do I have to do for it to stop and then close it? I never make GUI animations so I am still kinda new to the whole Tweening and recognition stuff.

1 answer

Log in to vote
0
Answered by 5 years ago

So you actually don't need two scripts, you can simply use 1 LocalScript. Now, your problem is that the way your Tween is structured, the "override" default is still set to false meaning that if another tween would try to start playing, it can't.

You can easily fix this by just completing all parameters of the tween and setting "override" to true

I added the local variable in case you wanted to move the LocalScript somewhere else, then you wouldn't have to adjust every line of code pertaining to script.Parent, just the top line.

local frame = script.Parent

frame.MouseEnter:Connect(function()
    frame:TweenSize(UDim2.new(0, 216, 0, 216), "Out", "Quad", 1, true, nil)
end)

frame.MouseLeave:Connect(function()
    frame:TweenSize(UDim2.new(0, 60, 0, 216), "Out", "Quad", 1, true, nil)
end)
0
Thank you very much for the solution. Lualaxy 78 — 5y
Ad

Answer this question