GetGuiObjectsAtPosition only returns correct result for top half of image objects?

I’m trying to use this function for my custom inventory system so the player can drag the item down to the hotbar to add it to the slot they want it in. The issue is that this function is only partially detecting one of my frames in the inventory.

If I click at a position in the bottom half of the frame, the method does not pick it up at all, but if I click the top half of it then it does.

This is affecting my development by making this function unusable. It happens 100% of the time. This bug happens in Studio and probably happens in a live server too, I am using PC with Windows 10 x64. It started happening as soon as I noticed it, around 30 minutes ago, but has probably been happening much longer than that.

Repro:

Make a frame and try the function with your mouse position upon click. Try clicking the frame in several positions on the frame. You’ll notice the method only returns a sensible result on the top half of the frame.

Repro UI model: Repro Gui 2.rbxm (11.5 KB)

  • Add it to StarterGui.
  • Start play solo.
  • Start clicking the button with the energy sword.

I use different elements like UIAspectRatioConstraint and UIGridLayout in a scrolling frame which sorts the smaller frames.

Media:

There’s like an offset which makes the function think the frame is in the position of the top half and half the size of the frame outside the top of it.

https://gyazo.com/7890e3e07799a4f0365060e930f39d6f

Picture of the explorer if this helps at all:
image

The white box is where it seems the functions thinks the Frame is.
image

If you need any more information please let me know.

So what is happening here is that you are using the position without the GuiInset removed so it is offset by the size of the top bar. UserInputService:GetMouseLocation() does not take the GuiInset into account. Change the line:

local MouseLocation = UserInputService:GetMouseLocation()

To:

local MouseLocation = Input.Position
7 Likes