Now I accomplished that by just manually setting the rotation property of the red frame, but how would I get the angle that the red frame should be at if I wanted it to point towards the green frame using a script?

First you’ll need to find the centre positions of both of the GuiObjects. You can do this by adding half the AbsoluteSize to the AbsolutePosition. Then find the difference between the two GuiObjects by subtracting the X and Y components from the previous calculations.

Once you have a dX (change in X) and dY (change in Y), resort to some trigonometry.

math.tan(theta) = opposite/adjacent

So:

math.tan(theta) = dX/dY

Use the atan2 (or tan inverse) function to rearrange:

math.atan2(dY, dX) = theta (I believe atan2 does it in that order)

And there you have you angle (theta) in radians. You can convert this to degrees by using math.deg(theta)

local GuiObject = script.Parent --Imaginary GuiObject
local AbsSize = GuiObject.AbsoluteSize
local AbsPos = GuiObject.AbsolutePosition
local newPositionX = AbsPos.X+(0.5*AbsSize.X)
local newPositionY = AbsPos.Y+(0.5*AbsSize.Y)

If you imagine a line, if you have the position at the very left of the line, but you want the middle. Simply add half of its length. This is the same concept, we’re just doing it on the X and Y to get the centre of the 2D box

So one of your Guis was very tall and very thin. If we used the .Position.X and .Y then we would choose our angle from the top left of the Frame, because that’s how Gui position is calculated. This could cause the angle to be incorrect, so we find the very centre of the frame and calculate from that so we get the correct angle.

We can see that O and P are the 2 points that we need to find the difference of. We can get X by getting the distance by subtracting and getting the absolute value.

local X = math.abs(P.X - O.X)
local Y = math.abs(P.Y - O.Y)

Now that we have the lengths of the triangle, we need to find the value of θ. To do that, we will utilize the atan2 function: an extended version of the tangent inverse function. To do this, we will have to input the numbers Y and X. I believe in using atan2 as opposed to the classic atan function due to it utilizing the signs of the numbers to determine the quadrant, and it being able to handle 0 properly. This makes it best in this case.

local Theta = math.atan2(Y, X)

Theta (θ) is the the angle from point O to point P, and that is your answer.

If you want more information, check out this article.