This method only works for star-planet systems that have orbits aligned in such a way that, as seen from Earth, the planet travels between us and the star and temporarily blocks some of the light from the star once every orbit.
The transit method consists of regularly measuring the luminosity of a star in order to detect the periodic decrease in luminosity associated with the transit of an exoplanet. The transit happen when a planet passes in front of its star. On the other hand, when the planet passes behing the star, it is called an eclipse. The effect measured during a transit is quite small. For a star the size of the Sun, the transit of a Jupiter-size planet will cause a decrease in apparent luminosity of about 1%, while this decrease will be of about 0.001% for a planet the size of the Earth.
This is a video of how transit method works.
Here you can learn more.