Why do we subtract the position of PartA from PartB in every instance of using magnitude?
print((workspace.PartA.Position - workspace.PartB.Position).magnitude)
It has to do a little bit with how physics works and basic vector addition/subtraction. The way that the character's position
works is that it's tracked by a vector's magnitude from (0,0,0) and updated from there.
With this, subtracting someone's position from another position doesn't exactly return a distance, it returns another vector. The "magnitude" is simply the length of this vector, as a vector is defined by having both a magnitude
and direction
.
By subtracting the the position of PartB from PartA, you are getting a vector3 value which is the difference between the two values. For example, if you have a part at 100, 200, 100 and another at -50, -100, -50, the difference between the two positions would be 150, 300, 150. After you get the difference, you use .magnitude to basically get the length of a straight line from the position 0,0,0 to the difference between the positions of the two parts. Sorry if this explanation is a bit hard to understand.