How big is a magnitude difference of less than 100?

I have the following line of script in my code:

	if (pos -part.Position).Magnitude <= 100 then

How far away (in studs) could the following line return true for? 100 studs? or is it the cube root of 100?

100 studs.
(In your code, less than or equal to 100 studs.)

1 Like

when I set it do 10 studs, for example, it is not 10 studs… I have to get like, with in 2 or so studs

In a Vector3, .Magnitude finds the length of the vector. You are subtracting the position of the part from the position of “pos”, and finding the length of the resultant vector. This should, in theory, be the exact distance between the parts - you might be overestimating how long a stud is.

I believe the formula for .Magnitude is the Pythagorean theorem. The length it yields is in other words the hypotenuse of the vector, which means the length. This returns the actual length, which means you are likely miss-interpreting the desired length.

Could you provide an example for when it doesn’t actually give a the length you want?

EDIT: You are saying “I have to get”, which indicates you are using the char. Remember that it is a 3d space, which means the X, Y and Z axis contribute to the length, and your HumanoidRootPart is likely not on the same altitude as the target.

1 Like