Need some guidance with BillboardGUIs and line drawing

Currently, I am working on a project and within it, I have a conundrum. I’m attempting to draw a line in the form of a frame between an ImageLabel within a BillboardGUI and a part in the workspace (HumanoidRootPart). I’m aware of how to convert a Vector3 to UDim2 using WorldToScreenPoint, however, it still does not work properly. I was hoping some god-tier mathematicians could read over my code and see where I’m going wrong. The associated function is below, with all the necessary variable information provided. Any advice would be greatly appreciated, and before you say it, no, AbsolutePosition does not work.

--[[
TargetPart is the HumanoidRootPart
BaseHolder is the BillboardGUI
Point is an ImageLabel that I am using as one of the two origin points for the line
ConnectorPart is a Frame that I am using as the line to connect between two 2D points
]]--
    local TargetPart = Character:WaitForChild("HumanoidRootPart")
	local TargetPosition = CurrentCamera:WorldToScreenPoint(TargetPart.Position)
	TargetPosition = UDim2.new(0, TargetPosition.X, 0, TargetPosition.Y)
	local HolderPosition = CurrentCamera:WorldToScreenPoint(TargetPart.Position + BaseHolder.ExtentsOffset)
	HolderPosition = UDim2.new(0, HolderPosition.X, 0, HolderPosition.Y)
	local PointPosition = UDim2.new(0, Point.AbsolutePosition.X, 0, Point.AbsolutePosition.Y) + HolderPosition
	
	ConnectorPart.Size = UDim2.fromOffset(
		math.sqrt(
			(PointPosition.X.Offset-TargetPosition.X.Offset)^2+(PointPosition.Y.Offset-TargetPosition.Y.Offset)^2
		),
		5
	)
	ConnectorPart.Position = UDim2.fromOffset(
		(PointPosition.X.Offset+TargetPosition.X.Offset)/2, (PointPosition.Y.Offset+TargetPosition.Y.Offset)/2
	)	
	ConnectorPart.Rotation = math.deg(
		math.atan2(
			(PointPosition.Y.Offset-TargetPosition.Y.Offset), (PointPosition.X.Offset-TargetPosition.X.Offset)
		)
	)

Again, any advice is welcome, my math skills aren’t the greatest, and this problem has been stressing me for hours, so it hasn’t helped with the math lol. Thanks in advance!

Is there a reason why you can’t use an actual part instead of a frame? The two targets are not part of the 2D GUI. Seems like it would be much easier to use part and not a frame. If the part is created on the client side, then only that client can see it.

Well I was converting the 3D position of the HumanoidRootPart to the 2D on-screen position in pixels, then using the on-screen position of the BillboardGUI within the above equations to generate a straight line with a frame in a ScreenGUI, as I am using screen positions of the two elements, it only makes sense to translate the results to an object in a container that maintains the size of the screen, regardless, I forgot to update yesterday, but I got it working now. The problem wasn’t with the equation, it was with the position of where the Point was, but that has since been rectified now.

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