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:
1 | firstpart = workspace.Part |
2 | playerTorso = workspace.Player 1. Torso |
3 |
4 |
5 |
6 | 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)
You would use magnitude. It gets the distance between 2 Vector3 Values.
1 | firstpart = workspace.Part |
2 | playerTorso = workspace.Player 1. Torso |
3 |
4 | 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. :)