I have a problem when the player starts hovering over the button several times, then it will shrink and shrink.
This is how it looks (sorry for audio):
here is script:
local gui = script.Parent
local tInfo = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local function on_Hover(frame)
TweenService:Create(frame, tInfo, {Size = UDim2.new(frame.Size.X.Scale * 1.25, 0, frame.Size.Y.Scale * 1.25, 0)}):Play()
end
local function not_Hover(frame)
TweenService:Create(frame, tInfo, {Size = UDim2.new(frame.Size.X.Scale / 1.25, 0, frame.Size.Y.Scale / 1.25, 0)}):Play()
end
for i, button in pairs(gui:GetDescendants()) do
if button:IsA("TextButton") then
button.MouseEnter:Connect(function()
on_Hover(button)
end)
button.MouseLeave:Connect(function()
not_Hover(button)
end)
end
end
I believe it’s just best for you to store a constant of the initial size, and then tween back to that size when your mouse leaves:
local gui = script.Parent
local tInfo = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local ButtonDefaults = {} -- Table of the default sizes
local function on_Hover(frame)
TweenService:Create(frame, tInfo, {
Size = UDim2.fromScale(
ButtonDefaults[frame.Name].X.Scale * 1.25,
ButtonDefaults[frame.Name].Y.Scale * 1.25
) -- Set the size to the default size * 1.25 (or any amount!)
}):Play()
end
local function not_Hover(frame)
TweenService:Create(frame, tInfo, {Size = ButtonDefaults[frame.Name]}):Play() -- Reset the size to the default
end
for i, button in pairs(gui:GetDescendants()) do
if button:IsA("TextButton") then
ButtonDefaults[button.Name] = button.Size -- Add the original size to the table
button.MouseEnter:Connect(function()
on_Hover(button)
end)
button.MouseLeave:Connect(function()
not_Hover(button)
end)
end
end
Hope this helps you out a bit, let me know of any concerns!