Could someone help me? I am thoroughly confused. I have a command in my datapack that is executed from load.json function:
execute unless entity @e
[type=armor_stand,name=team_lives,scores={first_time_setup=1}]
run summon armor_stand 0 255 0 {Tags:["armor_stand_life"],
Invisible:4b,Invulnerable:4b,PersistenceRequired:4b,NoBasePlate:4b,NoGravity:4b,
CustomName:'{"text":"team_lives"}',DisabledSlots:4444959}
Basically, what this will do is unless first_time_setup (the score) = 1
then it will summon a new armor stand. first_time_setup is automatically set to 1 with another function, and I checked there is an armor stand in the world that has first_time_setup=1
which means that is should not summon a new one.
When I run it via a command block nothing happens like it should. But for some reason, when it's in the datapack (despite me having ran it via command block and it working as intended) it summons a new armor stand (but it shouldn't).
I'm doing this in single player, and I've noticed that it only happens when I leave/re-join a world, so it has to be coming from the load.json function, since when I disable/re-enable the datapack nothing breaks. This leads me to believe that here may be a time between load.json loading and running the command then the the world fully loading (with the armor stand in it). So it might be that the armor stand isn't loaded at the time it checks.
Either way any ideas?