How to play sounds to wherever an npc or player is?

I have NPCs that play sound when you click them, using the playsound command. It works fine for NPCs who are stationary, as I know what the coordinates will be. But for NPCs that move around, how can I specify relative coordinates? I tried the ~ ~ ~ but that just plays the sound at the server spawn, which is far away from the npc.
6 Replies
Admincraft Meta
Admincraft Meta2mo ago
Thanks for asking your question!
Make sure to provide as much helpful information as possible such as logs/what you tried and what your exact issue is
Make sure to mark solved when issue is solved!!!
/close !close !solved !answered
Requested by nuttapillar#0
Nuttapillar
NuttapillarOP2mo ago
also, even though I'm using @p, it seems to be playing to the player who is closest to spawn, rather than who is closest to the npc
TinnyFusion
TinnyFusion2mo ago
Instead of using @ p couldn’t you use PAPI to target the actual player that is interacting with the NPC such as %player% (or whatever it is, can’t remember off the top of my head)?
Nuttapillar
NuttapillarOP2mo ago
hmm, well the citizens support told me to use a -p flag which seemed to fix this, but thank you, thats something i can keep in mind too
TinnyFusion
TinnyFusion4w ago
Could you share an example of one of the commands you are using when an NPC is clicked?
Nuttapillar
NuttapillarOP4w ago
commands: '0': command: playsound custom.karen1 voice @p ~ ~ ~ 100

Did you find this page helpful?