help me with a command

I'm trying to make a feature which allows you to keep your loot when killed specifcally only by players. i made a scoreboard objectives "Pvp" , u get 1 score when killed by a player set a repeating command block with the command- execute as @a[scores={Pvp=1..}] run gamerule keepInventory true (Unconditional) Followed by two chain command blocks- scoreboard players reset @a Pvp (Unconditional) > gamerule keepInventory false (Unconditional) Despite the efforts, players drop their loot as usual when killed other players. Why doesn't it work?
Continue to help post