If the star is the same size as our sun, then at some stage, the hydrogen in the star begins to run out. At this point, the outward force due to fusion energy is less than the inward force due to gravity. This causes the star to collapse inwards. The collapse of the star causes its temperature to increase. Now helium nuclei fuse together to create heavier elements.