I have tried looking around for the answer, but I kept on getting answers for playing a sound on death. I want to play a sound when player respawns. Any suggestions?
1 Answer
For a solution, you can set up a scoreboard objective, deaths, with /scoreboard objectives add deaths deathCount
. This will increment every time a player dies. Next, you need to set up another objective, health, with scoreboard objectives add health health
. This will be used to check if a player is alive.
Then, place a repeating command block with the command execute @a[scores={deaths=1..,health=1..}] playsound ambient.cave master @s
which leads into a chain command block with the command execute @a[scores={deaths=1..,health=1..}] scoreboard players reset @s deaths
. This combination will first play a sound at every player with more than one death and that is alive, and then reset their deaths.
Hope this helps!
-
what version is this? the repeating command block command doesn't seem to work in 1.16.4.– SubhamJan 8, 2021 at 5:45
-
i tried editing it to repeating command block:
execute as @a[scores={deaths=1..,health=1..}] run playsound ambient.cave master @s
and chain command block:execute as @a[scores={deaths=1..,health=1..}] run scoreboard players reset @s deaths
, but the sound plays when the player dies, not on respawn which I want– SubhamJan 8, 2021 at 5:55