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.
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)