I wanna make a code that let you drop you items on death when you got killed by a player and when not it wouldn't drop your items. I have tried this but it doesn't work. Can anyone help me?
Code:
on death:
if attacker is a player:
if victim is a player:
execute console command "/gamerule keepInventory false"
wait 1 tick
execute console command "/gamerule keepInventory true"