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

Is it possible to break a TweenPosition tween?

Asked by
1GlF 42
5 years ago

Basically, I want to stop a tween that is already running (without disabling the script). How could I do that?

0
btw its a gui 1GlF 42 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Hello awesomejoker248674,

Question:

So You want to start another tween in the middle of another tween when an action is carried out? So for example, when you hover over a button, you want a tween to play, but when you remove your mouse, you want another tween to play.

Solution:

What you are looking for is Override ( which can be found here ) It's a bool value.

In my place, I have it so when you put your mouse over a text button, it will get slightly longer, and when you move your mouse off it, it will decrease in size.

Code:

local button = script.Parent

button.MouseEnter:Connect(function()
     for i = 1,0,-0.25 do
    button.BackgroundTransparency = i
    wait(0.01)
    button:TweenSize(UDim2.new(0, 220, 0 ,50), "In", "Linear", 0.2, true) -- The true here indicates that you want the tween to be over ran by another tween
    end

end)

button.MouseLeave:Connect(function()
     for i = 0,1,0.25 do
    button.BackgroundTransparency = i
    wait(0.01)
    button:TweenSize(UDim2.new(0, 200, 0 ,50), "Out", "Linear", 0.2, true)  -- The true here indicates that you want the tween to be over ran by another tween. So if I rapidly take put my mouse back on the button when the tween is playing, it will start to play the Tween for Mouse Enter. 
    end

end)

I hope this helped, If it did, put [SOLVED] in the title or accept an Answer!

0
i will try that in a sec 1GlF 42 — 5y
0
yup, works 1GlF 42 — 5y
0
yeah, No problem bud tonyv537 95 — 5y
Ad

Answer this question