Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Volt3Z 40
6 years ago

I already had a problem similar to yours and it seems like you can't do maths with UDim2 you would more need to use the tweenposition instead of math.If you have any question comment my answer and i will respond to you as fats as i can.Hope i helped you! ;)

link: http://wiki.roblox.com/index.php?title=API:Class/GuiObject/TweenPosition

0
not really what i needed but thanks anyway herobenjamin321 -4 — 6y
Ad

Answer this question