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

Distance between two blocks

Asked by
Trewier 146
10 years ago

How would I figure out the distance between two blocks. Would I use magnitude?

1 answer

Log in to vote
2
Answered by 10 years ago
local part1 = Instance.new("Part", workspace)
part1.Position = Vector3.new(0, 20, 0)
local part2 = Instance.new("Part", workspace)
part2.Position = Vector3.new(0, 0, 0)
print((part1.Position-part2.Position).magnitude) --20

Every Vector3 has a magnitude. In the above example, it is used to get the distance of studs of two parts. See more here.

Ad

Answer this question