Calculating Distance Between 2 Chars

How would I go on about to calculate the distance of 2 characters. Calculating only the _x-axis between the two. And how would I go on to make a certain action if a certain distance between the two is reached?

Thanks in advance.