TweenService Not working Help!

I’m trying to make it so once the players mouse enters the frame, the frame tweens, but for some reason it isn’t working, although it’s printing the message.

Code:

local shopButton = script.Parent:WaitForChild("ShopButton") -- frame

local startsize = UDim2.new(script.Parent.Size.Width.Scale, 0, script.Parent.Size.Height.Scale, 0)

local hoversize = UDim2.new(script.Parent.Size.Width.Scale * 1.05, 0, script.Parent.Size.Height.Scale * 1.05, 0) --change 1.05 to whatever works for you

script.Parent.MouseEnter:Connect(function()
	shopButton:TweenSize(hoversize,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,.25,true)
	print("mouse Enter") -- Printing that works but not tween
end)

script.Parent.MouseLeave:Connect(function()
	shopButton:TweenSize(startsize,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,.25,true)
end)

Can we see the Gui in the Explorer please?

You also can try this and see if it works:

local shopButton = script.Parent:WaitForChild("ShopButton") -- frame

local startsize = UDim2.new(script.Parent.Size.Width.Scale, 0, script.Parent.Size.Height.Scale, 0)

local hoversize = UDim2.new(script.Parent.Size.Width.Scale * 1.05, 0, script.Parent.Size.Height.Scale * 1.05, 0) --change 1.05 to whatever works for you

shopButton.MouseEnter:Connect(function()
	shopButton:TweenSize(hoversize,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,.25,true)
	print("mouse Enter") -- Printing that works but not tween
end)

shopButton.MouseLeave:Connect(function()
	shopButton:TweenSize(startsize,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,.25,true)
end)

Thats not working, here is a video showing that it prints but doesn’t tween

2023-12-07 13-01-29

You’re calculating the starting and hovering size wrong.

Code:

local TweenService = game:GetService("TweenService")

local shopButton = script.Parent:WaitForChild("ShopButton") -- frame
local originalSize = shopButton.Size

local tweenInfo = TweenInfo.new(0.25, Enum.EasingStyle.Sine)

shopButton.MouseEnter:Connect(function()
	TweenService:Create(shopButton, tweenInfo, {
		Size = UDim2.fromScale(originalSize.Size.X.Scale * 1.05, originalSize.Size.Y.Scale * 1.05)
	}):Play()
end)

shopButton.MouseLeave:Connect(function()
	TweenService:Create(shopButton, tweenInfo, {
		Size = originalSize
	}):Play()
end)
1 Like

I’m getting an error stating " Size is not a valid member of UDim2 - Client - ButtonHandler:13"

i removed the extra size variables on line 13 and its not printing any errors, but it’s not working either

Although it wouldnt tween the frame, when i parented it with the imageButton instead it tweened that, so I guess that will work. Thankyou for your help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.