If you, or anyone else is wondering how .magnitude works, I made a functioning example of .magnitude, for comparing the magnitude of two points - basically the distance between them. And let me know if anyone has feedback on this, like if I’m doing something wrong - keep in mind it’s not customized for roblox Vector3 values (but the x,y,z is the same as how Vector3 works), but works for vanilla lua.

I like experimenting with formulas such as this - it’s fun!

```
local function magnitude(a, b)
local delta = {math.abs(a[1] - b[1]), math.abs(a[2] - b[2]), math.abs(a[3] - b[3])}
local mag = math.sqrt(delta[1] ^ 2 + delta[2] ^ 2 + delta[3] ^ 2)
print("One: " .. delta[1] .. " Two: " .. delta[2] .. " Three: " .. delta[3])
print("Magnitude: " .. mag)
return mag
end
```

**So example usage would be:**

```
local firstPosition = {6, 2, 1}
local secondPosition = {1, 2, 6}
magnitude(firstPosition, secondPosition)
```

**And the output for the above:**

One: 5 Two: 0 Three: 5

Magnitude: 7.0710678118655

So basically, magnitude in this use-case subtracts the first vector’s values by the second vector’s values (vice versa), and takes the absolute value of the results from them. Then it uses the pythagorean theorum to calculate the final magnitude.

In turn, you could take the direct distance between any two objects in a 3D space that have vectors with the x, y, and z axis’. And you can use this for 2D points as well, by simply changing the formula to not include the z axis (the third number).

But anyhow, I hope I helped somewhat in understanding (to some degree) what’s happening behind the scenes with .magnitude. Have a great week!