I am trying to make a series of command (used by the player by having right-click with an item trigger the said series of commands) that checks if the player is in a team, then if they aren't, creates a team for them and automatically adds them to the said team, and summon a hostile mob with the same team.

so far, I could only make:

/team join ally @p 
/summon zombie ~ ~ ~ {Tags:["ally"]}
/execute as @e[type=zombie, tag=ally] run team join ally

this is rather unreliable since the mobs will not target the player who used the item once to join the team 'ally'. any workaround for this or a way to create team for each player that uses the item for the first time? Version is 1.20.4


1 Answer 1


The command to add a player to a team is /team join team_name player name, and you can do the same with /team join team_name @e[type=zombie,team=team_name], and you should get the hostile mob (example zombie) on your team; it shouldn't attack you or anyone, or mob, on your team.

You must log in to answer this question.

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