You used the word legions in your question in a way that seems to refer to the Roman army as a whole, I may be presuming there but I just want to start with a bit of description of the late army. The legions are commonly seen as a relatively tight order, heavy-infantry fighting force, equipped in full body armour with large, rectangular shields and straight-edged short swords. This was the mainstay of the Roman army of the Republic and early Empire. The legion was a standardised unit – under Augustus each of the 28 legions had 5,120 men. The legions were supported by the auxilia, a non-citizen army which comprised all of the Roman cavalry, archers, scouts, light infantry, and even some heavy infantry. The army was roughly divided 50/50 between legions and auxilia.
By the fifth century, when the Empire collapsed, this was totally different. After all, more than four-hundred years had passed – the goals of the Roman army had changed from expansion to maintaining the borders, and the enemies Rome faced had also changed. The legion was still an army unit, but it was less standard – roughly one-thousand men, most likely usually less. They were also no longer the heavy-infantry I described above. The Column of Arcadius, destroyed by an earthquake but fortunately preserved in drawings by a sixteenth-century German traveller, shows the marching army of the eastern Roman Empire carrying large spears and no shields, and being cladded mostly in mail or other lighter, scale armour. Similarly, the wooden Diptych of Stilicho portrays him with similar armaments. Very different to the heavy legions of Augustus and the early Empire.
The auxilia had also disappeared and had essentially been replaced by foederati – units recruited from Rome’s barbarian allies. This was really not too different from the method through which the auxilia were recruited and used, even though modern scholarship has falsely lambasted this policy as being responsible for the collapse of the Empire. The biggest difference was in loyalty – the foederati typically kept their own commanders and officers, whereas the auxilia were commanded by officers appointed by Rome. Thus in the fifth century about half the army was loyal to non-Roman commanders, and these commanders were only loyal to Rome when it suited them. Alaric I, commander of a large group of Visigothic foderati, used anger and discontent at the casualties his men faced during the Battle of the Frigidus to stage a rebellion against the eastern Empire. Thus while largely the same in martial strength as the auxilia, the loyalty of the foederati left much to be desired.
As the Empire suffered continuing defeats over the course of the fifth century many of the units that guarded the Roman frontiers were drafted into the permanent regional field armies called comitatenses. Eventually, the distinction between border guards and field armies became non-existent as imperial control rarely extended outside Italy unless a Roman general (commonly of barbarian origins and with close personal ties to his army) took his forces on a campaign. This fact, combined with the fact that Roman imperial collapse was a gradual process rather than a quick one, meant that there were very few armies left in the lurch when the Empire actually did collapse in 476. One example that did last past this date, is the short-lived Kingdom of Soissons. Emperor Majorian appointed Aegidius as magister militum (‘Master of Soldiers’, basically the regional general) of Gaul. However barbarian tribes pushed across the Rhine and down into the Iberian Peninsula, effectively garrisoning that territory and cutting Aegidius and his armies off from Rome. Aegidius’ armies essentially became a de facto state at that point, forming an alliancea with Childeric, the king of the Franks, and with tribes in Britain. After his death in 464, Aegidius’ son Syagrius became ruler, a further indication that this was essentially already a kingdom, because magister militum was not a hereditary position. In 476 Syagrius did not accept the rule of Odoacer, who had overthrown the Roman emperor in Italy, and therefore became an officially separate state even though they stylised themselves as simply ruling a Roman province. Childeric’s son, Clovis, did not continue the alliance with Syagrius and made continued war against him, eventually defeating the Roman in 486 and taking his territory for himself. Syagrius was executed not long after. This is probably the best example of a Roman army maintaining loyalty after the fall of the Roman emperors. Although primary evidence is sorely lacking for the fifth century and maybe there are other similar events I am not aware of, most other armies kept loyalty to their foederati commanders and amalgamated into the other kingdoms that succeeded Rome. Only the Kingdom of Soissons kept official allegiance to the Roman Empire.