Pretty self explanatory, i would like to get some more help on magnitude
Magnitude is always described as the "distance between two objects", which is totally wrong.
.magnitude
is a property of Vector3 (vector3, cframe and a lot of other datatypes count as an object) and magnitude simply means "length", and in other cases it might mean a quantity a size and everything that goes along that. Vectors (or we can day Vector3s as we know them in roblox) are lines that have a direction and a length, or as we said a magnitude.
Here is an example
local vector = Vector3.new(5, 2, 3) print(vector.magnitude) --prints out around 6.16, which is the length of this vector in studs
The most common use for .magnitude
is finding the distance between two things. That's by subtracting the first position from the 2nd position (positions are just vector3s of course), that subtraction should gives us another vector that describes the distance between those two positions, so technically the magnitude of that vector is the distance between those 2 vectors.
Think about it's pretty simple.
local distance = (part1.Position - part2.Position).magnitude print(distance)
And this is not the only use for magnitude, there are A LOT especially when you're dealing with math. And really, here is a great advise, there isn't always an answer to "when would I use this?", what you should do is learn this stuff, and one day when you stumble across something you don't know, you try to think of a solution for that and maybe you needed the length of a vector so you use it!
Have a good day!
https://developer.roblox.com/en-us/articles/Magnitude
I mostly use it to find the absolute distance in studs between two objects, for an example:
Magni = (ObjectX.Position - ObjectY.Position).Magnitude
print(Magni)
it will print the distance in studs between the 2 objects