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

GUI Button not returning to regular size?

Asked by 3 years ago

Hello! This is my first post here so sorry if I miss anything, and I'm very new to scripting.

I'm trying to make it so a GUI button's size changes on mouse hover and click. So far this part is working, except for one thing. I have put the exact parameters shown in the buttons property tag for its size in the script, yet when the script is fired through a mouse hover, it squashes into a different size and won't go back to it's normal size. I've tried even using the frame's dimensions instead, yet this hasn't helped.

Here is my script:

local btn = script.Parent

local isHovering = false


btn.MouseEnter:Connect(function()

    isHovering = true

    btn:TweenSize(UDim2.new(0.537, 0, 0.594, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)

btn.MouseLeave:Connect(function()

    isHovering = false

    btn:TweenSize(UDim2.new(0.517, 0, 0.574, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)

btn.MouseButton1Down:Connect(function()

    btn:TweenSize(UDim2.new(0.507, 0, 0.554, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)

btn.MouseButton1Up:Connect(function()

    if not isHovering then
        btn:TweenSize(UDim2.new(0.517, 0, 0.574, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
    else
        btn:TweenSize(UDim2.new(0.537, 0, 0.594, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
    end
end)

And here is what the problem is: Size and Hovering Issue

Thanks for any help in advance! I'm expecting it to be an obvious solution that I'm just blind to-

1 answer

Log in to vote
0
Answered by 3 years ago

I haven't tested this myself but I'm pretty sure you use the wrong size in your script. {0, 517}, {0, 574} (the original size in your screenshot) is much different from {0.517, 0}, {0.574, 0} (the size in your script) as far as gui size goes.

0
and i think that dionsyran2 66 — 3y
0
Oooh I see what you mean, I think I’ve formatted it wrong. I’ll give that a test later, thanks! DragonessAnimations 6 — 3y
Ad

Answer this question