I have a gui and a script. I'm trying to make my gui stretch when a mouse goes inside of the button that's in the gui. The problem is that for some reason, whenever my mouse leaves the button it doesn't shrink.I don't know what the problem is.
local xScale = script.Parent.Size.X.Scale local xOffset = script.Parent.Size.X.Offset local yScale = script.Parent.Size.Y.Scale local yOffset = script.Parent.Size.Y.Offset script.Parent.MouseEnter:Connect(function() script.Parent:TweenSize(UDim2.new(xScale,xOffset+100,yScale,yOffset), Enum.EasingDirection.Out, Enum.EasingStyle.Quint,.5) end) script.Parent.MouseLeave:Connect(function() script.Parent:TweenSize(UDim2.new(xScale,xOffset-100,yScale,yOffset), Enum.EasingDirection.In, Enum.EasingStyle.Quint,.5) print("shrinked") end)
Have you tried;
script.Parent.MouseEnter:Connect(function() script.Parent:TweenSize(UDim2.new(xScale,xOffset+100,yScale,yOffset), Enum.EasingDirection.Out, Enum.EasingStyle.Quint,.5,true) end) script.Parent.MouseLeave:Connect(function() script.Parent:TweenSize(UDim2.new(xScale,xOffset-100,yScale,yOffset), Enum.EasingDirection.In, Enum.EasingStyle.Quint,.5,true) print("shrinked") end)
Becuse the fifth parameter is "override" and if set to true, any new tweening will override the current one.
Make this become this:
local xScale = script.Parent.Size.X.Scale local xOffset = script.Parent.Size.X.Offset local yScale = script.Parent.Size.Y.Scale local yOffset = script.Parent.Size.Y.Offset script.Parent.MouseEnter:Connect(function() script.Parent:TweenSize(UDim2.new(xScale,xOffset+100,yScale,yOffset), Enum.EasingDirection.Out, Enum.EasingStyle.Quint,.5) end) script.Parent.MouseLeave:Connect(function() script.Parent:TweenSize(UDim2.new(xScale,xOffset,yScale,yOffset), Enum.EasingDirection.In, Enum.EasingStyle.Quint,.5) print("shrinked") end)
(xScale,xOffset-100,yScale,yOffset)
is not need here, it is because the EasingSytle already ease'd it out.
But I don't know how to explain, just use that script, anyways.
If this is correct, don't forget to mark this as the correct answer, thanks :) cheers