I want to give myself a random (@r) player's head on my server but I don't know if this is possible.

I'm on Minecraft 1.14.4 and when I place minecraft:give @p player_head{SkullOwner:"@r"} into a command block, it simply gives me the player head of "@r"

(I also found that without putting the quotation marks around the @r in the command, the command wouldn't be valid)

give command in command block

player head of @r in hotbar

  • 2
    usually, you can use the JSON text components to specify a selector like this: "{\"selector\":\"@p\"}". This concept can be used on signs, the /tellraw command and for a few more things but not for something like this. Is your server a Bukkit/Spigot server by any chance? because if so, you can use a plugin for that. Nov 30, 2019 at 22:17
  • It's possible to do with loot tables, but a bit complicated. Good question! I'll figure it out later today and then answer if nobody does until then. Dec 1, 2019 at 0:37

1 Answer 1


You need a loot table (archive) and the command /loot (archive) for this.

Firstly, the loot table that gives (or summons or inserts or whatever) the head of the player it is invoked on.
Minimal file structure of the datapack:


Here head_loot is an arbitrarily chosen namespace, which is reused in the command later. The same with head.json, only the file extension needs to be .json.

Contents of pack.mcmeta can vary depending on what you want, but this is a minimum example:


Contents of head.json:

 "pools": [
   "rolls": 1,
   "entries": [

Now you can create heads of arbitrary (currently online) players. There are multiple ways to do this, the one that is actually intended for exactly this is:

/execute as @r run loot spawn ~ ~ ~ loot head_loot:head

This runs "as" a random player, but not "at" their position and summons a player head item entity at the execution position (a command block or whatever).

Make sure that the datapack is enabled, this command tells you that:

/datapack list

If you just changed something in the files, use /reload.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .