I know by getting the player's mouse you can click on a "BasePart" class, and get the information via using Target after getting the mouse. But how do you get Gui classes by clicking them with the mouse?
You're asking a very vague question. To my understanding, your question is revolving around a gui being clicked. Some GUIs on ROBLOX have a property that allows them to be selected, such such a TextButton. Inside of those GUIs, there are usually local scripts that fire when the local player clicks them.
function onClick() --Execute code end script.Parent.MouseButton1Click:Connect(onClick)
In that manner, I guess you can make it print the name of the script's Parent lol. Another interpretation of your question is: "Using a single script, how do I get to know when a button is clicked?" -- I've done things like that before, but it's normally when all the buttons have the same "Parent" because that makes things easier. You will first loop the script into all the children, then tie a function when they're clicked. Here's a quick one I'll make:
local PARENTOFALL = script.Parent for i, child in pairs (PARENTOFALL:GetChildren()) do if child.ClassName == ("ImageButton") or child.ClassName == ("TextButton") then-- adjust this if you want child.MouseButton1Down:Connect(function() print(child.Name) end) end end
I just made this code so it might have a small typo of some sort, but I hope you get the idea. You're meant to loop the local script into all the buttons, then have a code doing whatever, using the buttons name's.. Your question is very vague but I hope I helped a bit!