There are many ways to measure the distance of star.
Here's one technique: Triangulation or parallax
When we want to measure a distance of star, first we get the star's position in the sky at a certain time. Then after that, astronomers then wait for six months (because it would take Earth six months before it can reach the end of its orbit). After six months, we then get the position of that star again - and then we then compare it with its data from the last time it was taken (but everything like the Earth's orbit, the position of the sun, the movement of the Earth in relation with the movement of the solar system through the Milky Way Galaxy and your current position must be taken into consideration to minimize error). This small difference of the star's position is what we call stellar parallax or the relative motion of the star in relation with your movement. You then compare your data with the already known stars. That's how you get the star's distance, which is quite tricky.