I am creating a function pack for the bedrock edition of Minecraft. In one of the commands, I want to give the tag ‘test’ to @s (the player running the command) if they do not already have the tag and remove ‘test’ if they already have it.

How would I do this?

1 Answer 1


The following commands should do the trick:

execute @s[tag=test] ~ ~ ~ tag @s add has_test
execute @s[tag=!has_test] tag @s remove test
execute @s[tag=has_test] ~ ~ ~ tag @s add test
tag @s remove has_test

The logic is basically that if it has the tag, it will remember it for the whole command chain then.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .