Prevent mouse click going through GUI controls

Hi,

I’m working on a placement system which uses GUI buttons to rotate the object being placed, these buttons are used for mobile support. You tap the screen to place the item or click the Place button. The object moves relative to the mouse position and when you click the place button it is placed. However, the issue I have is that when I click the Rotate Button on mobile, the mouse click goes straight through the GUI button and immediately places the object in a completely different area. Doesn’t even rotate the object as it is already placed before the script has time to rotate it - placed in the position of where I tapped the Rotate Button. I just want to rotate it - not place it at the same time in a different area! I use UserInputService to detect the mouse movement and move the object to the mouse’s target. Is there anyway to fix this so that the object doesn’t move when I click the GUI - and only when the mouse target is not over a GUI object?

The issue is most prominent on mobile because a GUI tap initiates the placing.

Thanks.

Video: robloxapp 20180514 1124475 - Sendvid

4 Likes

Not sure if it’s exactly what you want, but isn’t there a “gameProcessedEvent” bool on InputBegan / TouchStarted to see if the input began on top of a GuiObject.

5 Likes

Thanks, will have a look at that.

1 Like

Just set the GUI object’s (or in your case, button’s) Active property to true.

Sorry for the bump. I was scrolling around this category and it seems like it’s not solved yet.

12 Likes