Is this the best way to make a gui hover animation?

Hey im a beginner scripter and im wondering if this is the best way to make a gui hover animation just as a reminder the code DOES work but when you put your mouse on the gui then take it away real quick it either doesnt play the animation or it gets big and doesnt go back small or vise versa.

Local Script Code

playButton.MouseEnter:Connect(function()
	playButton:TweenSizeAndPosition(UDim2.new(0.8, 0,0.097, 0),UDim2.new(0.1, 0, 0.329, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1)
	script.Parent.ButtonHoverSound:Play()
	playButton.MouseLeave:Connect(function()
	playButton:TweenSizeAndPosition(UDim2.new(0.714, 0,0.083, 0),UDim2.new(0.143, 0, 0.336, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1)
	end)
end)

MouseEnter should never be used due to its unreliability. You could create a custom module that handles these events, or use an open sourced module that fixes this problem.

1 Like

It seems to do the same thing and i have no idea how to make a custom module as i said im a beginner scripter.

Thats why I provided an open source module that should be used instead of MouseEnter.

1 Like

I just said the module does the same thing. Basicly its slightly better because when you intitally hover it will do the tween no matter what but when you stop hovering really quick it doesnt tween you have to wait a full second for it to actually work then you can stop hovering.

I fixed it! I just had to set the over ride in progress tweens on the tweens to true and it worked!

I don’t get why the .MouseLeave connection is inside the .MouseEnter connection…
But good job on fixing it.

1 Like