Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with gui that goes from one point to your mouse?

I tried making a line that follows one point to your mouse, but it worked when i used it on two parts but because the center of a gui is in the left corner it was very wierd. I have tried fixing in a multiple ways it but none worked.

mouse = script.Parent.Parent.Parent.Parent:GetMouse()
node = script.Parent.Parent.Frame.Nodein1
line = script.Parent

function move()
	local x1 = node.AbsolutePosition.X+25
	local y1 = node.AbsolutePosition.Y+25
	local x2 = mouse.X
	local y2 = mouse.Y
	local deg = math.atan2(y1-y2,x1-x2)*180.0/math.pi
	line.Size = UDim2.new(0,math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)),0,10) 
	line.Position = UDim2.new(0,(x1+x2)/2-5,0,(y1+y2)/2-5)
	line.Rotation = deg
	print(deg)
end

mouse.Move:connect(move)

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.