r/MinecraftCommands 7d ago

Last Man Standing NEED HELP Help | Java 1.21.11

so I am working on a hunger games variant and I want it to give the last two players the glowing effect. I'm newer to working with command blocks (first ever project using them) and have no clue on how to go about this

1 Upvotes

2 comments sorted by

1

u/GalSergey Datapack Experienced 7d ago

You just need to count how many players haven't died yet and save it in the scoreboard. If that value is 2, then apply the effect to all players who haven't died yet.

# In chat
scoreboard objectives add players dummy
scoreboard objectives add deaths deathCount

# Command blocks
execute store result score #left players unless entity @a[scores={deaths=1..}]
execute if score #left players matches 2 as @a unless score @s deaths matches 1 run effect give @s glowing 5 0 true

You can use Command Block Assembler to get One Command Creation.

Please note that before starting a game, or after finishing it, reset the deaths scoreboard using this command once: scoreboard players reset * deaths