Minecraft – How to summon a Zombie that doesn’t attack me but attacks the other players

minecraft-commandsminecraft-java-edition

I am working on a Minecraft map and I came across this. I am trying to make a special ability so that you can summon a Zombie that doesn't attack you but attacks the other players.

Best Answer

A mob will not try to attack you if you are on the same team as it. For example, you can create a team:

/scoreboard teams add FriendlyMobs

Then add yourself and the zombie to the team:

/scoreboard teams join FriendlyMobs @p @e[type=Zombie]

You could also summon the zombie already on the team:

/summon Zombie ~ ~ ~ {Team:"FriendlyMobs"}