Added null check for player object, should hopefully fix bug