Connecting two points with a line

I have been trying to connect two points in a UI with a line but cant seem to get the X offset right. Any ideas?

My code:

		local Line = Dot2.Line
		local Distance = (Dot2.AbsolutePosition - Dot1.AbsolutePosition)
		local OriginPos = getOriginAbs(Line)
		local Center = (Dot1.AbsolutePosition + Dot2.AbsolutePosition)/2
		
		Line.Rotation = math.deg(math.atan2(Distance.Y,Distance.X))
		Line.Visible = true
		Line.Size = UDim2.new(0, Distance.Magnitude, 0, 2)
		Line.Position = UDim2.fromOffset(Center.X, Center.Y) - UDim2.fromOffset(OriginPos.X, OriginPos.Y)

What I currently have:
image

Definitely try an internet search first. You will find this many times if you do. Here is one of them:

I already looked through a lot of posts including that one but it didn’t seem the work on my script

Can you show how you called the DrawLine function within your code. Maybe I can see what you did wrong?

try this for the OriginPos

local OriginPos = Dot2.AbsolutePosition - Dot2.AbsoluteSize/2

i just set it to Dot2’s absolute position since its the parent and remove half its size to center it

It looks like the positions are the position of the TextLabel rather than the dot.

that is this

ffffffffffffffffff

the dot is the parent and i never asked for the position of the textlabel in the script also when i test on mobile it is not on the position of the textlabel

i was able to fix it for all devices by multiplying it by 1.4206 something but i don’t know why this number works