local frameCenter = frame.AbsolutePosition + (frame.AbsoluteSize/2) --Get the center of the frame
This will get the center of the frame, because the default anchor point of a UI frame is top-left, so we currently have the position of this pivot (top-left), to get the position of the center of the frame (x and y) we have to increment half of the pivot position to itself, this should be better to understand:
Sorry for the bad drawing, hope you understand
And the part that I add 90:
local r = math.deg(x) + 90
As I said is a padding, because the X and Y of the mouse are not very precise, and for you to understand remove this addition to see what happens
Edit: About the first one, here is another recent topic that could explain a little better: