How can I target the same player that was previously targeted randomly?

I am making a Minecraft commands map and need to give a random player two effects and one item.

I understand that each effect/item needs to be given in a separate command. The problem is, @r targets a random player each time, but I need the effects and items to be given to the same randomly targeted player.

How can I give these effects/items to the same player?


Solution 1:

  1. Tag the random player.
    /tag @r add RandomSelection 
    
    Note, your tag name should not contain spaces!
  2. Give them the effects and item by targeting the player with the tag.
    /effect @a[tag=RandomSelection] fire_resistance
    /give @a[tag=RandomSelection] stone
    
  3. Remove the tag.
    /tag @a[tag=RandomSelection] remove RandomSelection