Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you find the distance between the edges of parts? (UNANSWERED)

Asked by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

Magnitude finds the distance between the center of parts, like this

print((workspace.Part1.Position - workspace.Part2.Position).magnitude)

But if you have large bricks, they can be touching and still have a fairly large magnitude. I was wondering if there was a way to find the distance between the edges of parts, aka the number of studs between them. It should not be affected by their size.

0
Someone has to know... Perci1 4988 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

I don't know if this will help but this is what I am using at the moment

math.sqrt((part2.Position.X - part1.Position.X)^2 + (part2.Position.Z - part1.Position.Z)^2)
0
That did not work. It did not give me a number even close to the distance between the edges of parts. Perci1 4988 — 9y
Ad

Answer this question