Do you want to select some units for the player, or get the units that the player has selected? You said a script will run with the selected units so I assumed it was the latter.
_array = groupSelectedUnits player; // Will return units selected with F2, F3...
// Will select the first two units, highlighting them in the group bar
player groupSelectUnit [(units player) select 1, true];
player groupSelectUnit [(units player) select 2, true];