How can I fit a UI Frame between 2 points?

Hello, this is my first devforum post.

The issue

As mentioned on the title, I want to fit a frame between 2 points by using a script. I’ve tried lots of things but none of them worked. This is a screenshot of an example of what I want to achieve.

Also, I want it to be on the “offset” type of the size property! Thank you for reading the post.

You would place the frame at the position of the first point (and move it to the middle of it for effect you want), then you can just subtract the positions of the 2 points to get the size needed for the frame:

frame.Position = point1.Position+UDim2.new(0,point1.Size.X.Offset/2,0,point1.Size.Y.Offset/2)
frame.Size = (point2.Position-point1.Position)

This works with scale too, you just need to replace
UDim2.new(0,point1.Size.X.Offset/2,0,point1.Size.Y.Offset/2)
with
UDim2.new(point1.Size.X.Scale/2,0,point1.Size.Y.Scale/2,0).

Thank you so much for helping me. The script you provided worked!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.