Basically, I want to stop a tween that is already running (without disabling the script). How could I do that?
✓ ANSWER ACCEPTED
Is it possible to break a TweenPosition tween?
1 answer
✓ Accepted answer
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!
3 comments
0
i will try that in a sec
0
yup, works
0
yeah, No problem bud
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
btw its a gui