First of all, your line should be while (!player) {wait (1);} or while(player == null) {wait (1);}
Then, you should put the line I've told you about inside your player action.