This is what I have tried, but this finds the Global distance:
distanceX = part1.CFrame.X - part2.CFrame.X
I have experimented with CFrame.lookVector, but I couldn't get that working either. Does anyone know how I can accomplish this?
Vector.magnitude
print((part1.Position - part2.Position).magnitude)