GUI Mouse Hover Problem

I made an inventory GUI that displays an items information when your mouse hovers over it and makes the information disappear when your mouse isn’t hovering over it. The problem is it doesn’t do this very efficiently. When there are alot of items in your inventory sometimes it doesn’t pop up when your mouse is over it.

Demonstration:

As you can see sometimes the information doesn’t pop up when the mouse is over it.

Every GUI Button has this script in it:

script.Parent.MouseEnter:Connect(function()
	Template.Visible = true
end)

script.Parent.MouseLeave:Connect(function()
	Template.Visible = false
end)

Is there any way to make this more efficient?

1 Like

MouseLeave aren’t always guaranteed to fire up before the MouseEnter of another element. So maybe it overrides each other.

My thoughts about this is that you should unify the buttons script to one script and keep track and manage the buttons and the active one to efficiently switch.

1 Like

The reasoning behind this is if you are currently selecting a ui element, you cant enter another one. (That’s how the events are coded) So, if you move your mouse too quickly, it jumps from one button to another. This means you cant just connect the simple events.

The easiest way to get around this is track the mouse’s x and y position, and check to see if they are inside a certain button.

3 Likes