I want to check if the top right corner and the bottom right corner of a frame overlap with another frame, how would I do this?

1 Like

You can use GetGuiObjectsAtPosition:

You’d have to create your own method for getting the bottom or top right corners though, I can help if you need it.

I asked for getting the far right corners so if you could help thatd be ideal

1 Like

Sure.

To find the top & bottom right:

```
local playerGui = game:GetService('Players').LocalPlayer.PlayerGui
local screenGui = Instance.new('ScreenGui')
screenGui.Parent = playerGui
local myFrame = Instance.new('Frame')
myFrame.Parent = screenGui
local topRightCorner = Vector2.new(myFrame.AbsolutePosition.X + myFrame.AbsoluteSize.X, myFrame.AbsolutePosition.Y) -- construct a new Vector2 value from the top right corner.
local bottomRightCorner = Vector2.new(myFrame.AbsolutePosition.X + myFrame.AbsoluteSize.X, myFrame.AbsolutePosition.Y, myFrame.AbsoluteSize.Y -- should get the bottom right corner
local objectsAtTopRight = playerGui:GetGuiObjectsAtPosition(topRightCorner.X, topRightCorner.Y) -- this method returns a table which we will use table.find to find a specified object.
local objectsAtBottomRight = playerGui:GetGuiObjectsAtPosition(bottomRightCorner.X, bottomRightCorner.Y)
```

Here’s where you’d use the top left and top right variables:

```
local objectToCheckOverlap = screenGui.NewFrame -- you'd have to create your own frame for this.
if table.find(objectsAtTopRight, objectToCheckOverlap) and table.Find(objectsAtBottomRight, objectToCheckOverlap) then -- if the object is found at the top right and bottom right then
-- your argument
end
```

```
function collides(gui1, gui2)
local g1p, g1s = gui1.AbsePosition, gui1.AbsoluteSize;
local g2p, g2s = gui2.AbsolutePo.x > g2p.x) and (g1p.y < g2p.y + g2s.y and g1p.y + g1s.y > g2p.y));
4
end;
```

1 Like