I have a piece of code that make a button enlarge on hover and shrink when unhovered. If I move my mouse out of the button mid animation it breaks and stops tweening.
local tweenservice = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local function click(v)
local ogSize = v.Size
local goal2 = {}
goal2.Size = ogSize
local tweeninfo = TweenInfo.new(
0.2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
local goal = {}
goal.Size = ogSize + UDim2.new(0.1,0,0.1,0)
local tween2 = tweenservice:Create(v,tweeninfo,goal2)
local tween = tweenservice:Create(v,tweeninfo,goal)
v.MouseEnter:Connect(function()
tween2:Cancel()
tween:Play()
script["button hover sound for memi"]:Play()
end)
v.MouseLeave:Connect(function()
tween:Cancel()
tween2:Play()
script["Button Click Release"]:Play()
end)
end
for i,v in ipairs(script.Parent:GetChildren()) do
if v:IsA("TextButton") and v.Name == "Customization" or v.Name == "Play" or v.Name == "Settings" then
click(v)
end
end