GuiButton: MouseEnter event misfires after clicks


I want to use TextButton.AutoButtonColor = false and do custom button coloring behavior using MouseEnter, MouseLeave, Button1Up, and Button1Down. Here is my code:

[code]local guiButton = script.Parent

print(“Mouse enter”)
guiButton.BackgroundColor3 =, 0.5, 0.5)

print(“Mouse leave”)
guiButton.BackgroundColor3 =, 1, 1)

print(“Button down”)
guiButton.BackgroundColor3 =, 1, 0)
guiButton.BorderSizePixel = 10

print(“Button up”)
guiButton.BackgroundColor3 =, 0.5, 0.5)
guiButton.BorderSizePixel = 0

The border size is expanded whenever the button is yellow, which is when the button is pushed (button 1 down). Notice that according to the code, the border should only be expanded when the button is yellow, and vice versa.

However this is not case. There are two strange behaviors to the MouseEnter function that causes this:

  1. If the last two events called were MouseButton1Down, then MouseButton1Up (a click), then MouseEnter will be called immediately after the mouse next moves.
  2. Again, if the last two events were down and up (a click), but this time we don’t move the mouse but instead do another MouseButton1Down, MouseEnter will be called immediately after that last MouseButton1Down call.

In my case, this is causing the color changing effects of my mouse enter function to override the color changing effects of the mouse down function, since the mouse enter function is misfiring immediately after the button down function is called. This is the second problem case above.

MouseEnterRepro.rbxl (12.4 KB)