How do I make it so when one player dies everyone dies
I'm trying to make something like the life link challenge for a realm but can't use a plugin on it so I've been trying to make it using command blocks.
it's in 1.14.4 so old commands won't work
Solution 1:
First, type in chat:
/scoreboard objectives add deaths deathCount
Then, set two command blocks, one set to 'repeat' and 'Always active' and another linked to the first set to 'chain', 'Always active' and 'Condicional' as in this image. Then, you add the following commands respectively:
/execute as @a[scores={deaths=1..}] at @s run scoreboard players set @a deaths 0
/kill @a
The way it works is simple: If a players die, the scoreboard will register and add a point to whoever died. After that, the command block will execute as the player (note that the command could go 'execute if @a[scores={deaths=1..}]') and clear everyone (including his) score. The second command will only activate if the first one was sucessful and if it happends, the command will kill every player in the server.
To avoid such, you can do:
/tag [PlayerName] add LifeLink
And modify the first two commands as well as adding another one set to 'repeat' and 'Always active':
/execute as @a[scores={deaths=1..},tag=Lifelink] at @s run scoreboard players set @a deaths 0
/kill @a[tag=LifeLink]
/scoreboard players set @a[tag=!LifeLink] deaths 0
It will only kill and activate the commands if such player is set with the LifeLink tag.
Here are some Images to help build it.
Place the first block down:
Shift and then right click to place the second one. Make sure they are pointing in one direction (http://prntscr.com/p9kwvb).
Open the first command block. Paste the command bellow and set as 'Repeat' and 'Always Active':
/execute as @a[scores={deaths=1..}] at @s run scoreboard players set @a deaths 0
Open the second command block. Paste the command bellow and set it to 'Chain', 'Conditional' (Super important, don't miss it) and 'Always Active'.
/kill @a
The final product.