I need to find what gui the cursor is on, but can’t find a good way to do it.
I’ve tried GetGuiObjectsAtPosition and given it the mouse position from GetMouseLocation, but for some reason it doesn’t work (thinks the cursor is on something when it’s not & vice versa).
Also, I know of MouseEnter and MouseLeave functions but I’m using a lot of gui’s and would rather not create like 80 events just to do this one thing
GetGuiObjectsAtPosition would return whatever GUI objects the mouse is over, whether it is transparent or not. Go through the objects and remove them from the table if its ScreenGUI isn’t enabled or the object is transparent.
mouse enter and mouse leave could work, even though you dont want to make 80 events. you can just make a separate function that connects the mouse enter event and mouse leave, then use a for loop to connect all of them to the function you made
for i, v in pairs(REPLACETHIS:GetDescendants()) do
if v:IsA("Frame") then -- add more stuff
v.MouseEnter:Connect(function()
print(v);
end);
v.MouseLeave:Connect(function()
print(v);
end);
end;
end;
I don’t see any reason why :GetGuiObjectsAtPosition() would not work unless you are not taking into account the offset created from the GuiInset. You can offset this by doing something like this: