I would like to run the /playsound in the position of a creeper named red, but it doesn't seem to target mobs, is there a way around this? Maybe using the execute subject?

execute at @a as @e[type=minecraft:creeper,name=red,distance=..10] run playsound minecraft:entity.creeper.primed hostile @a[distance=..10] ~ ~ ~
  • What is the command? What you've already tried, or something else? – Name_Hr3 Oct 16 at 21:44

You are executing the command at every player online as the creeper. That is most likely causing the problem. To fix this use the following command.

execute as @a at @s run execute as @e[type=minecraft:creeper, name=red, distance=..10] at @s run playsound minecraft:entity.creeper.primed hostile @a[distance=..10] ~ ~ ~

This command runs the whole second execute command as the players at the players which runs the play sound command as and at the creepers in range of the players targeted at the players in range. Your command runs the playsound command at the players targeted at the players. I have not tested this but this seems to be what you are trying to accomplish. If this doesn't work check the syntax of the playsound command. Check as well if the sound is a actual sound. I hope this helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.