Detecting a direct mouse click on a GUI in regular client environment is straight-forward: just set-up an event for that specific object. Though when it comes to implementing something like that in a studio environment, it's more complicated. As we all know, GUI objects don't detect plugin mouse input when the GUI is located in the StarterGui container. That's a major issue when it comes to a GUI editor plugin, as it is perferrable to allow the user to select the actually GUI with their mouse rather than selecting in the Explorer menu.

=======================================================================

My intial solution to this problem was to have the plugin replicate all children of the specified ScreenGui to the CoreGui container, and replicate everything back to the StarterGui whenever there was mouse input detected that directly changed a property of a GUI object.
In other words:

|StarterGui| - |ScreenGui| ==(Replication every studio Heartbeat)==> |CoreGui|

|CoreGui| ==(Replication whenever there is mouse input)==> |StarterGui| - |ScreenGui|

Pros

  • Z-Index of GUI is taken into account when the mouse clicks on an object

  • Doesn't interfere with other GUI

Cons

  • More complex and advanced

  • May cause more lag

  • Incompatible with un-doing and re-doing edits

This method works well in general. I have attempted to write the code for it, but I was unable to get it to work due to the complexity of such.

=======================================================================

Another method I considered using involved the plugin iterating through all GUI objects and checking if a mouse click was within an object:

Pros

  • Simple and straight-forward

Cons

  • Doesn't take into account the Z-index of an object

  • May cause more lag

=======================================================================

The last solution to this issue I could think of is somehow building off of the built-in roblox UI Editor. I don't know exactly how someone would go about doing this, though

Pros

  • Most of the workload is handled by the Studio plugin

  • Simple and Straight-forward

Cons

  • May not continue to work after an update to the Studio plugin

  • Developing a Gui Editor along-side it may be more complicated and lead to further issues

Which method would you suggest I use? Do you have any other solutions to my issue you? Comments, suggestions, and feedback would be much appreciated. Thanks!

Note: If you're wondering why this is a re-post to a question originally asked in the ScriptingHelpers 'Questions' section, it's because the original post didn't get much of a respone and someone suggested that I post it here instead. Here's the link to the original version --> Original Post Link