Gui after clicked is stuck in the clicked size

When I click the Gui it makes the size go smaller but after it has been clicked it is stuck in the clicked size. I would like it to either go back to the hover size it the player is still hovering the mouse over it or if the player is no longer hovering over it then go back to normal after it has been clicked. If anyone could help me I would really appreciate it.

1 Like

Well what’s wrong with it? And in this context MouseButton1Click and MouseButton1Up will fire at the same time. Consider using MouseButton1Down to get the connection when the player has pressed down on the button, and using MouseButton1Up to go back to your hover size.

Hi once you’ve clicked it and you still hover over the gui without taking your mouse off it. It stays in the click size until you have taken your mouse off it. I want it to go back to the hover size if the player has left their mouse on it after clicking it.

don’t ever use TweenSize and TweenPosition in MouseEnter events, it is super laggy.

Instead, use TweenService

game.TweenService:Create(script.Parent, TweenInfo.new(.25), {Size = startSize}):Play()

That’s because you’re setting the size to presssize in the mousebutton1up, which is where you need to be setting it to hover size

I’ll explain it in order of events with how you programmed it:
Players hovers → Frame tweens to hover size
Player Clicks → Frame tweens to press size
Player Lets Click Go → Frame tweens to press size again

Instead you need to do this:
Players hovers → Frame tweens to hover size
Player Clicks → Frame tweens to press size
Player Lets Click Go → Frame tweens to HOVER size

Your error is on line 20, instead of this

script.Parent:TweenSize(pressize,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,.1,true)

It needs to be this

script.Parent:TweenSize(hoversize,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,.1,true)

Also change line 15 to this:
script.Parent.MouseButton1Down:Connect(function()

You’re connecting to a click which is a full press down and lift up, which it needs to be only a down press

1 Like

his code is absolutely correct, tween functions just dont stack on rapid events, unlike tweenservice

You’re incorrect my friend, his problem is that the button is tweening to the same size, and its sticking there, if he wants the button to tween back to the hover size, it needs to tween to this value, hes instead tweening to the press size inside of his mousebutton1up event, which will just leave it at the size it was

Instead when the player lets go of the click while still hovering over the button, he needs to tween it back to the hover size

1 Like

oh wait, you’re right.

sorry for the inconvenience :slightly_smiling_face:

1 Like

No apologies needed, it’s okay :slight_smile:

1 Like

Oh ok thank you just changed it and it worked. I’m kind of new to scripting. It’s my first time making a Gui animation.

2 Likes

No worries, I’m glad its fixed!

1 Like

TweenService is better than TweenSize and position, due to them being laggy in MouseEnter?

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