TweenSize not working

script.Parent.MouseEnter:Connect(function(x, y)
	script.Parent:TweenSize(UDim2.new(.2, 0, .2, 0), Enum.EasingDirection.In, Enum.EasingStyle.Back, .2, true)
end)

script.Parent.MouseLeave:Connect(function(x, y)
	script.Parent:TweenSize(UDim2.new(.1, 0, .1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, .2, true)
end)

I’ve put print statements in both of these. Both do in fact run through the lines of code when they are supposed to- it’s just that there’s absolutely zero movement.
The size isn’t too small to notice either, it’s using relative scale and these are the exact same values I have in another TweenSize from earlier (that works perfectly)

What’s going wrong?

3 Likes

First, ensure that script.Parent is a GuiObject of some sort.

If you can ensure that, then I would recommend the use of TweenService instead of TweenSize. Personally, I find it to work better than TweenSize. Below is code for the equivalent of using TweenSize with TweenService:

local TweenService = game:GetService("TweenService")

local mouseEnterTweenInfo = TweenInfo.new(.2, Enum.EasingStyle.Back, Enum.EasingDirection.In)
local mouseEnterGoal = {}
mouseEnterGoal.Size = UDim2.new(.2, 0, .2, 0)
local mouseEnterTween = TweenService:Create(script.Parent, mouseEnterTweenInfo, mouseEnterGoal)

local mouseLeaveTweenInfo = TweenInfo.new(.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
local mouseLeaveGoal = {}
mouseLeaveGoal.Size = UDim2.new(.1, 0, .1, 0)
local mouseLeaveTween = TweenService:Create(script.Parent, mouseLeaveTweenInfo, mouseLeaveGoal)

script.Parent.MouseEnter:Connect(function()
	mouseEnterTween:Play()
end)

script.Parent.MouseLeave:Connect(function()
	mouseLeaveTween:Play()
end)

Let me know if this works for you!

My bad

Yeah turns out I had a recursive callback function that repeatedly tweened it back to its original size so I got rid of that and it works fine

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