Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local abs, sqrt, floor, deg, acos, pow = math.abs, math.sqrt, math.floor, math.deg, math.acos, math.pow
- local distance = function(point1, point2)
- return floor(abs(sqrt(pow(point2.Y - point1.Y, 2) + pow(point2.X - point1.X, 2))))
- end
- local angle = function(point1, point2)
- return(deg(acos((point2.X - point1.X) / (distance(point1, point2)))))
- end
- local newLine = function(point1, point2)
- local line = Instance.new("TextLabel", script.Parent)
- line.Text = ""
- line.Size = UDim2.new(0, distance(point1, point2), 0, 2)
- line.Position = UDim2.new(0, point1.X --[[ MINUS SOME OFFSET THING HERE?? ]], 0, point1.Y + ((point2.Y - point1.Y) / 2))
- line.Rotation = angle(point1, point2)
- --this just draws points so i can see where the line SHOULD be, not relevant
- local x1 = Instance.new("TextLabel", script.Parent)
- x1.Size = UDim2.new(0, 2, 0, 2)
- x1.Position = UDim2.new(0, point1.X, 0, point1.Y)
- x1.Text = ""
- x1.BackgroundColor3 = Color3.new(1, 0, 0)
- local x2 = Instance.new("TextLabel", script.Parent)
- x2.Size = UDim2.new(0, 2, 0, 2)
- x2.Position = UDim2.new(0, point2.X, 0, point2.Y)
- x2.Text = ""
- x2.BackgroundColor3 = Color3.new(1, 0, 0)
- end
- newLine(Vector2.new(100, 50), Vector2.new(180, 430))
- newLine(Vector2.new(300, 300), Vector2.new(500, 300))
Advertisement
Add Comment
Please, Sign In to add comment