That’s one way of detecting exoplanets, but not the most common one.
There are a couple of ways we can detect exoplanets:
We can see a wobble in the position of the star, as the star and the planet orbit around their common center of mass, which is offset from the center of mass of the star due to the mass of the planet.
Another way is to observe the light from a star, as the planet passes in front of the star some of the light gets blocked by the planet. By measuring the time and amount of light blocked, we can tell a lot about what is doing the blocking. The benefit of this method is some light passes through the atmosphere of the planet (if it has a significant atmosphere), by analyzing the spectrum we can tell what the atmosphere is made from.
We can also literally see a planet by direct observation, by blocking out the light of the central star, we can see light bouncing off the planet and observe that directly. This is hard, but has been done with several exoplanets.
That’s one way of detecting exoplanets, but not the most common one.
There are a couple of ways we can detect exoplanets:
We can see a wobble in the position of the star, as the star and the planet orbit around their common center of mass, which is offset from the center of mass of the star due to the mass of the planet.
Another way is to observe the light from a star, as the planet passes in front of the star some of the light gets blocked by the planet. By measuring the time and amount of light blocked, we can tell a lot about what is doing the blocking. The benefit of this method is some light passes through the atmosphere of the planet (if it has a significant atmosphere), by analyzing the spectrum we can tell what the atmosphere is made from.
We can also literally see a planet by direct observation, by blocking out the light of the central star, we can see light bouncing off the planet and observe that directly. This is hard, but has been done with several exoplanets.
There are more ways, see this Wikipedia article as a jumping off point for learning all about it: https://en.wikipedia.org/wiki/Methods_of_detecting_exoplanets