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

Vector2 magnitude is not working as it should be?

Asked by 5 years ago
  print((Vector2.new(script.Parent.Frame.Position) - Vector2.new(script.Parent.hi.Position)).magnitude)

It just returns 0, even though the 2 frames are far from eachother.

0
GUI Frames positions are UDdim2 values, not Vector2 values theking48989987 2147 — 5y
0
What do you use vector2 for then? Thesquid13 301 — 5y
0
yah, what the king said is right, Vector2.new() has only 2 arguments and they are x and y. while Udim2 has an offset and a scale for each x and y, so it has 4args. and i''m assuming the vector 2 just took the scale which im assuming you werent using so it was 0 for both x and y, and thats why the magnitude was 0. All though my expectation might be wrong starmaq 1290 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You don't need the Vector2.new part, as you're just subtracting one already-built vector2 from another.

print((script.Parent.Frame.Position -script.Parent.hi.Position).magnitude)
Ad

Answer this question