Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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)
0
Do there any errors, do you see output have a 'shrinked' word? Xapelize 2658 — 4y
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<) Y_VRN 246 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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

Answer this question