1

I'm trying to make a function, that when run, swaps the teams of two armor stands. I have this code written in a function on a repeating command block to set up the swap function, and the "less_num1" is the function that is supposed to swap them.

Set-up code:

execute if score @e[type=minecraft:armor_stand,team=ph,limit=1] time < @e[type=minecraft:armor_stand,team=num1,limit=1] time run function minigames:less_num1

This somewhat works, and it executes the function when it's supposed to, but the swap function that I wrote doesn't seem to work at all.

Swap Function:

execute as @e[type=minecraft:armor_stand,team=num1,limit=1,sort=nearest] run 
team join ph @s
execute as @e[type=minecraft:armor_stand,team=ph,limit=1,sort=nearest] run 
team join num1 @s

I have tried multiple variations of this and they don't seem to work either. When I run both of these commands by hand, they work, but they don't work in the function. Does anyone have a fix for this?

  • Do you maybe have another armour stand matching these conditions in the world? You didn't provide any sorting rule, so it selects one arbitrarily. Also, are you sure those conditions match for the armour stand you're checking? I just assigned an armour stand to a team without problems (and found out that teams apparently still use names for players, because my old username is in a team in my test world). – Fabian Röling Oct 31 at 8:40
  • I don't have any armor stand that has the same conditions. – Cobalt772 Oct 31 at 23:34
  • I even ran this command: /execute if score @e[team=ph,type=minecraft:armor_stand,limit=1] time <= @e[type=minecraft:armor_stand,team=num1,limit=1] time run say hi and nothing happened. The team ph armorstand had a score that was lower than it too @Fabian Röling – Cobalt772 Oct 31 at 23:35
  • Does the game log include any error messages? – Fabian Röling Nov 1 at 0:08
  • nope. I have send command feedback true and it does nothing – Cobalt772 Nov 1 at 0:15
1

You're putting everyone from one team into another team and then from that other team back into the first team. The result is that everyone ends up in the first team.

You need to put everyone from team A into a temporary team C, then everyone from team B Into team A, then everyone from team C into team B.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.