Answered by
8 years ago Edited 8 years ago
This only appears to happen upon hovering over GuiButton
objects. And unfortunately, there is no way to prevent this.
But there is a way around it.
You could use a TextLabel, along with the Button1Down
event, and check if the mouse is within the bounds of the GuiObject in order to simulate the MouseButton1Down
event.
This would look like this;
01 | local plr = game.Players.LocalPlayer; |
02 | local mouse = plr:GetMouse(); |
03 | local gui = script.Parent; |
04 | local xBounds,yBounds = gui.AbsoluteSize.X,gui.AbsoluteSize.Y; |
05 | local xPos,yPos = gui.AbsolutePosition.X,gui.AbsolutePosition.Y; |
07 | mouse.Button 1 Down:Connect( function () |
08 | local x,y = mouse.X,mouse.Y; |
09 | local leftui,rightui = xPos-xBounds,xPos+xBounds; |
10 | local upui,downui = yPos+yBounds,yPos-yBounds; |
11 | if (x < rightui and x > leftui) and (y < upui and y > downui) then |
12 | print ( "MouseButton1Down" ); |
Essentially, you can get the bounds of the GuiObject by adding/subtracting the AbsoluteSize by the AbsolutePosition.
So, left side of the ui would be: AbsolutePosition.X - AbsoluteSize.X
and the right side would be the same, but you add the AbsoluteSize rather than subtracting it. Same goes for the Y bounds.
Hope I helped! And happy developing!