I have this line of code (line 4) that should get the distance between two vectors. The two vectors are coming from a UDim though and I want to use Scale not Offset. Does Magnitude work for Scale or just Offset?

local LineSegment = script.LineSegment:Clone()
LineSegment.AnchorPoint = Vector2.new(0,0)
LineSegment.Position = UDim2.new(DataPoint.Position.X.Scale, 0, DataPoint.Position.Y.Scale, 0)
LineSegment.Size = UDim2.new((Vector2.new(DataPoint.Position.X.Scale, DataPoint.Position.Y.Scale) - Vector2.new(PrevDataPoint.Position.X.Scale, PrevDataPoint.Position.Y.Scale)).Magnitude - 1, 0, 0, 2)
LineSegment.Rotation = 180 - 180/math.pi*math.atan((DataPoint.Position.Y.Scale - PrevDataPoint.Position.Y.Scale)/(DataPoint.Position.X.Scale - PrevDataPoint.Position.X.Scale))
LineSegment.Parent = script.Parent.Plots
LineSegment.Name = "LineSegment" .. #(script.Parent.Plots:GetChildren())

Im expecting values much smaller then what its giving me.

If I cant how could I go about this some other way?

1 comment

0

Scale takes a number between 0-1. To convert your magnitude to scale you'd divide magnitude by the max magnitude