Minecraft – How to make players spawn with a sword after dying

minecraft-bedrock-editionminecraft-commands

I am making a bedwars map in Minecraft.

In real bedwars, when a player dies, they keep only their sword.

How can I make it so that players spawn with a wooden sword?

Best Answer

You need a death Counter first

/scoreboard objectives add deaths deathCount

I recommend functions but you can use a repeat command block and a chain command block, too

/execute as @a[scores={deaths=1..}] run give @s minecraft:iron_sword
/execute as @a[scores={deaths=1..}] run scoreboard players reset @s deaths