What if the "text" contains only one name (or better said element)? What would you say it happens?
Don't know what that regexp is supposed to do but if $text has just one element (is a list of unknown number of elements at this time) then it will fail to grab index number 1, 2, 3 and obviously 4 thus failing with an error. My guess is that you didn't see it because of that regexp doing something and execution is halted there.
Safest option in my opinion would be a
foreach loop over splitting that $text list cos it's not safe to trust your users input and based on how many of the "elements" need op, are on the channel and whatever other checks you want to add and then add them into another list that you just create then loop over it outside the first one to do the actual +o on each element you found in the first.
This has been discussed many times in the past so will let you figure out what code you actually need.
If you try something and get stuck then I will help you out.
Once the game is over, the king and the pawn go back in the same box.