Mmm Could it be there are more devices than players? I think there's a bug in this line in MAINMENU_UPDATE:
for i=0,2 do
Maybe it should be i=0,1. Can you try that, please?
That fixed it! :) Works perfectly now. Thank you!
(the change was on line 22, for reference)