When the core of a star like the sun uses up its supply of hydrogen for fusion, the core begins to contract in size. The gravitational forces becomes strong and cause the star to reduce in size. as the star contracts, the temperature of the star also rises since the heat is distributed inside smaller Volume now.