Trouble with hover tweening

i have 2 errors with tweening a image label, when hovering. the first error is that when i hover, it gets bigged for half a second, before going back to the normal size. and how do i make the label scale from the center, not the corner.

here is my script

local btn = script.Parent

local isHovering = false


btn.MouseEnter:Connect(function()

	isHovering = true

	btn:TweenSize(UDim2.new(0.064, 0,0.091, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.5, true)
end)

btn.MouseLeave:Connect(function()

	isHovering = false

	btn:TweenSize(UDim2.new(0.057, 0,0.11, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.5, true)
end)

btn.MouseButton1Down:Connect(function()

	btn:TweenSize(UDim2.new(0.055, 0,0.084, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.5, true)
end)

btn.MouseButton1Up:Connect(function()

	if not isHovering then
		btn:TweenSize(UDim2.new(0.057, 0,0.11, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.5, true)
	else
		btn:TweenSize(UDim2.new(0.064, 0,0.091, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.5, true)
	end
end)
2 Likes

Can you attach a GIF or video of what it’s doing?

To answer your second question, you can set the AnchorPoint to 0.5, 0.5.

2 Likes

https://vimeo.com/868136319?share=copy

1 Like
local btn = script.Parent
local mult = 1.1 -- // Edit this to your liking

local original = btn.Size
local target = UDim2.new(original.X.Scale * mult, 0, original.Y.Scale * mult, 0)

btn.MouseEnter:Connect(function()
	btn:TweenSize(target, Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1, true)
end)

btn.MouseLeave:Connect(function()
	btn:TweenSize(original, Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1, true)
end)

btn.MouseButton1Down:Connect(function()
	btn:TweenSize(original, Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1, true)
end)

btn.MouseButton1Up:Connect(function()
	btn:TweenSize(target, Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1, true)
end)
1 Like

it still scales in and out like before

I just put my code in a LocalScript inside of a TextButtton and it worked fine.

GIF (gyazo.com)

can you show me what parts you have inside of ur ui? coz i have a uiaspectratio constraint inside of mine

1 Like

i have this, it works but however when i click down, it doesnt come up… any idea why???
local button = script.Parent --Button

button.MouseEnter:Connect(function()
	button:TweenSize(
		UDim2.new(0.061, 0,0.091, 0),
		"In",
		"Quad",
		.2,
		false
	)
end)

button.MouseLeave:Connect(function()
	button:TweenSize(
		UDim2.new(0.057, 0,0.084, 0),
		"In",
		"Quad",
		.2,
		false
	)
end)

button.MouseButton1Down:Connect(function()
	button:TweenSize(
		UDim2.new(0.053, 0,0.082, 0),
		"In",
		"Quad",
		.2,
		false
	)
end)

button.MouseButton1Up:Connect(function()
	button:TweenSize(
		UDim2.new(0.057, 0,0.084, 0),
		"In",
		"Quad",
		.2,
		false
	)
end)
1 Like