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

Would you use magnitude to detect the nearest HumanoidRootPart?

I've never really used magnitude so I'm not sure how it works with Position.

2 comments

0

Position is a Vector3 x,y,z values magnitude = math.sqrt(x^2 + y^2 + z^2) this is the distance from 0,0,0 => the vector point

0

Thanks, this really helps bring light to what I'm thinking of.

1 answer

✓ Accepted answer

#Mhm! Good thinking.


The magnitude property of a Vector3 value allows you to determine the distance between two points. I'd do this by iterating over transparent objects named "HumanoidRootPart" that are in a range. It's not really efficient, so I encourage you to come up with a more efficient function that gets the job done.

Example of magnitude:

(rootPart1.Position - rootPart2.Position).magnitude

Happy coding!

1 comment

0

Ok, It makes alot more sense now, thank you for the insight, this was really helpful!

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