Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't my button shrinking when the cursor leave the button?

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)

2 comments

0

Do there any errors, do you see output have a 'shrinked' word?

0

This probably might work. In the TweenSize function, there's another paramater for override right after the time parameter. Try setting it to true. Like: gui:TweenSize(UDim2.new(too lazy 2 add), EasingDir, EasingStyle, 5, >true<)

2 answers

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.