Star formation: When a nebula collapses, is it only the gasses that form the star?
The very first stars to form indeed consisted essentially only of hydrogen and helium. When stars die, they leave behind them more massive atoms, as you say. These heavier elements are too incorporated in newer stars when they form. This results in stars which start out with a lower portion of hydrogen and helium, thus making them somewhat less effective; see for example this question and answer. The Sun, for instance, is a so-called third generation star, which means that it is made up of materials which have already been used at least twice since the Big Bang, and thus naturally contains heavier elements it has not produced itself.