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

Vector2 magnitude is not working as it should be?

  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.

3 comments

0

GUI Frames positions are UDdim2 values, not Vector2 values

0

What do you use vector2 for then?

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

1 answer

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)

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