Whatever energy one puts out is the energy they will receive.
Positive thoughts will bring positive experiences. Negative thoughts will bring negative experiences. The same goes for the energy that one attracts. Positive vibrational energy will attract positive energy. Negative vibrational energy will bring negative energy.
This closely relates to the concept of the “self fulfilling prophecy”. If one only focuses on what they think will go wrong, then things will most likely go wrong. If one remains optimistic and focuses on everything that can and will go right, then things will work out in their favor.
Like attracts like.