Does Tobler's First Law of Geography Apply to Star Composition?
As you say stars composition depend on the composition of the molecular cloud where they were created. You have a molecular cloud where many stars are being created at the same time, all with the same composition and age, but some are bigger than others. As time goes the bigger stars will die earlier, adding new heavier materials to the cloud which will lead to a new generation of stars with a bigger metalicity.

So the star's composition not only depends on where it was created but also on how old it is.

The best way this can be checked is by studying the stars within a star cluster. You may find this site interesting.