Okay so basically what is supposed to happen is the player throws down an item and it spawns an armour stand and a baby cow. The armour stand is supposed to follow the baby cow wherever it goes but it breaks as soon as there are two cows. It would also be handy if there is a way to kill the armour stand as soon as the cow dies since the armour stand is a "marker".
Commands:
execute as @e[type=item,nbt={OnGround:1b,Item:{Count:1b,tag:{PR1:1b}}}] at @s run particle block wheat[age=7] ~ ~0.8 ~ 0.1 0.1 0.1 1 20 normal
execute as @e[type=item,nbt={OnGround:1b,Item:{Count:1b,tag:{PR1:1b}}}] at @s run summon minecraft:armor_stand ~ ~ ~ {Small:1b,Marker:1b,Invisible:1b,NoBasePlate:1b,Tags:["P1"],DisabledSlots:4144959,ArmorItems:[{},{},{},{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:"54cef10f-bdaf-4fa6-928a-4db667394b84",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGZmNTIyOGE5MzhjNzVkNTRhZjY5ZDI4ZmQ4ZTlhMGI2NGEyOWJhYWFmMGE2Y2JlNzY4MWU2ZGI1ZDRlMmE4OSJ9fX0="}]}}}}]}
execute as @e[type=item,nbt={OnGround:1b,Item:{Count:1b,tag:{PR1:1b}}}] at @s run summon minecraft:cow ~ ~ ~ {Silent:1b,Age:-99999,AgeLocked:1b,Tags:["P1B"]}
execute as @e[tag=P1B] at @s run effect give @s minecraft:invisibility 7 0 true
execute as @e[tag=P1] at @s run tp @e[tag=P1] @e[distance=0..0.2,limit=1,sort=nearest,tag=P1B]
execute as @e[tag=P1] at @s run particle block wheat[age=7] ~ ~0.7 ~ 0 0 0 1 1 normal
execute as @e[type=item,nbt={OnGround:1b,Item:{Count:1b,tag:{PR1:1b}}}] at @s run kill @s[distance=..1]
ATTACHMENTS
The Cows have the glowing effect for demonstration of the issue
The issue is in your teleportation command. Because you used @e, it teleports all armor stands tagged "P1" to the same cow. Use @s instead of @e and it should work. To remove the armor stand:
/execute as @e[tag=P1] at @s unless entity @e[tag=P1B,distance=..0.3] run kill @s
Okay so basically what is supposed to happen is the player throws down an item and it spawns an armour stand and a baby cow. The armour stand is supposed to follow the baby cow wherever it goes but it breaks as soon as there are two cows. It would also be handy if there is a way to kill the armour stand as soon as the cow dies since the armour stand is a "marker".
Commands:
execute as @e[type=item,nbt={OnGround:1b,Item:{Count:1b,tag:{PR1:1b}}}] at @s run particle block wheat[age=7] ~ ~0.8 ~ 0.1 0.1 0.1 1 20 normal
execute as @e[type=item,nbt={OnGround:1b,Item:{Count:1b,tag:{PR1:1b}}}] at @s run summon minecraft:armor_stand ~ ~ ~ {Small:1b,Marker:1b,Invisible:1b,NoBasePlate:1b,Tags:["P1"],DisabledSlots:4144959,ArmorItems:[{},{},{},{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:"54cef10f-bdaf-4fa6-928a-4db667394b84",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGZmNTIyOGE5MzhjNzVkNTRhZjY5ZDI4ZmQ4ZTlhMGI2NGEyOWJhYWFmMGE2Y2JlNzY4MWU2ZGI1ZDRlMmE4OSJ9fX0="}]}}}}]}
execute as @e[type=item,nbt={OnGround:1b,Item:{Count:1b,tag:{PR1:1b}}}] at @s run summon minecraft:cow ~ ~ ~ {Silent:1b,Age:-99999,AgeLocked:1b,Tags:["P1B"]}
execute as @e[tag=P1B] at @s run effect give @s minecraft:invisibility 7 0 true
execute as @e[tag=P1] at @s run tp @e[tag=P1] @e[distance=0..0.2,limit=1,sort=nearest,tag=P1B]
execute as @e[tag=P1] at @s run particle block wheat[age=7] ~ ~0.7 ~ 0 0 0 1 1 normal
execute as @e[type=item,nbt={OnGround:1b,Item:{Count:1b,tag:{PR1:1b}}}] at @s run kill @s[distance=..1]
The issue is in your teleportation command. Because you used @e, it teleports all armor stands tagged "P1" to the same cow. Use @s instead of @e and it should work. To remove the armor stand:
Command block engineer // Developer // #TeamTrees
Thank you So much!