1

I am making a custom map with my friend, and at one part, you have to get scanned. If you're on team green it should say "Scan completed," but if they're on team red, it shouldn't say anything.

execute if entity @p[team=green] run say "Scan completed"

I've tried this code so far but didn't get any result.

What could be my issue here?

2
  • 1
    Welcome to Arqade, thanks for registering an account! There's some slight clarification needed here; which edition and version of Minecraft are you playing on? /execute has recently changed to look very similar in both Java and Bedrock, but the editions are still very different in other aspects of commands. It would be appreciated if you edit to add the minecraft-java-edition or minecraft-bedrock-edition tag to your question so we can provide an appropriate answer. Thanks in advance!
    – One 2 Many
    Oct 26, 2022 at 7:15
  • 2
    Per minecraft-commands tag wiki, "Please use either minecraft-java-edition, minecraft-bedrock-edition, or minecraft-education-edition together with this tag, depending on which game you play. Not using a tag specifying the game and not mentioning this anywhere else in the question will cause it to get closed as "Needs details or clarity". Casting close vote accordingly
    – pppery
    Dec 15, 2022 at 19:25

1 Answer 1

2

The code you have does work in Minecraft Java 1.19.2. I'm pretty sure it works in many earlier versions as well.

If you get any problems it might be because the command block is targeting a different player, remember that the selector:@p is selecting the closest player to the command block.

You might also have named the team wrong.

To add a team you would use this command:

/team add <team name> "display name"

ex:

/team add green "Green"

This will add team green with the display name Green. Remember that the names are case sensitive so if you used a lowercase when creating the team you need to use lowercase when testing for it.

And the name of the team is the green part, you can't(at least not to my knowledge) test for the display name of a team.

If you are on a server make sure that command blocks are enabled in the server properties.

1
  • Alright it did indead work, but was targeting the wrong person. A simple command block move fixed that Thanks! Oct 27, 2022 at 8:43

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