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 calculate distance between mouse.Hit.Position and char.PrimaryPart.Position?

I need help with calculating the distance between mousehitpos and character's pos. I'm doing a script where I want to teleport the player to their mousehit location and I also want to add a limiter to the distance they can teleport. But I can't seem to calculate distance between the player and the character pls help!

1 answer

✓ Accepted answer

Vector3 objects have a magnitude property which is basicly the vector length.

Using this you are able to get the distance between mouse and character.

(mouse.Hit.Position - character.HumanoidRootPart.Position).Magnitude

Accept if helps.

5 comments

0

:0

0

Can you please accept. If I helped yah.

0

yeah I will but I'll ask another question how can I like prevent the player from renaming textboxes

0

K. Ask that and accept this. I need 25 reputation to upvote my friend.

0

ok

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