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?