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

How do I identify how many studs are between a player and object?

I am wanting to find how many studs are between an object(a part) and a player(character model).

What I thought of that didn't work:

firstpart = workspace.Part
playerTorso = workspace.Player1.Torso



math.max(firstpart,playerTorso)-math.min(firstpart,playerTorso)

How could I do this?

(Also, I am just making this script to show what I did in a simplified version, I know it would be an error if I ran the script I provided)

1 answer

✓ Accepted answer

You would use magnitude. It gets the distance between 2 Vector3 Values.

firstpart = workspace.Part
playerTorso = workspace.Player1.Torso

local distance = (firstpart.Position - playerTorso.Position).magnitude

You would use "distance" to refer to the distance at any time.

You can read more on magnitude here.

Hope I helped. :)

1 comment

0

You did. I just remembered this term right when I saw the word magnitude. I feel so stupid LOL Thanks for helping!

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