Minecraft – how to make setblock a command block with a command that is executed at a certain player

minecraft-commandsminecraft-java-edition

I have made a minigame on my server, mctrees.net, using command blocks but it dosen't work with multiplayer so I would like to make it place the commands that run for the game but for it to make it specific to each player.
e.g. I have a command that usually gets run:

/setblock @p[r=10] dirt ~ ~10 ~ 

and I would like to make it setblock that command in a command block when a player (trebor97351) starts the game. it should setblock a command block with the command:

/setblock trebor97351[r=10] dirt ~ ~10 ~

How would I do this?
I know that you can place command blocks with prefilled commands but you can't specify a player when doing that?

Best Answer

By the way, unless you have a mod changing this, the syntax for /setblock has no player selectors. You can, however, use /execute, along with [name=], to accomplish this:

/execute @p[r=10,name=<username>] ~ ~ ~ setblock ~ ~10 ~ minecraft:dirt