The person is should have batted is the one "out".
The "illegal" batter is not out (unless they are put out during the at bat).
So here are some scenarios:
B6 is batting out of order (b5 should be batting) with no outs
for all scenarios, assume legal appeal for Batting out of order after the at bat.
1)and is walked.
B6 is removed from the base (all advances are nullified)
B5 is called out for BOO
2) grounds out
B6 is out (all outs stand, in this case, B6 grounded out)
B5 is out for BOO
3) w/ R1@1B, B6 grounds into a double play
R1 and B6 are out (all outs stand).
B5 is out for BOO (for the 3rd out)
4) w/R1@3B, B6 hits a single scoring R1.
B6 is removed from the base. (advance nullified)
R1 is put back to 3B (advance nullified)
B5 is out for BOO.