Early republican legionaries were split into 3 types.
Hastati were the younger, less experienced guys who made up the first line. They had 3 pila, shortsword, helmet, scutum(oval shield) but could rarely afford armour beyond a bronze square that covered the chest ( they paid for their own equipment).
Principes had previous experience and were more likely to be able to afford armour like a chain shirt. Mostly they were armed like Hastati, but sometimes had a Longspear like the Triarii instead.
Triarii were veterans. They were armed with longspears and scutums, they were theb last line of defence. The saying "it came down to the Triarii" signified a close desparate battle.
They deployed in a checkerboard formation against phalanx, so when one line got tired/depleted it could be releaved safely so it could retreat, regroup and form a reserve.
Velites were those too poor to be legionaries and scirmished with Javelin and shield. (or sometimes bow or sling)