Stars form inside dense, cold regions of gas and dust called molecular clouds. The formation of a star occurs when dense regions of this gas core collapse under their own gravity. As the cores collapse, they form into clumps which eventually make up protostars or baby stars which are still forming 🙂 As the protostar forms, gas falls into its center and this loosely falling gas releases kinetic energy in the form of heat. Infall stops when the star starts nuclear fusion (creation of the elements) and releases a stellar wind. This whole process can last up to millions of years.