Floating Pet Lantern - Multiplayer
I'm trying to make a datapack where in a specific condition, you'll have a lantern that emits light to float by your head as you go around. Singleplayer works, but when you try to do multiplayer, I have no idea what I did wrong to where it only works with one person, but for everyone else it will spawn a lantern in their position but not move it along, and when they go out of range of the one that spawned, another one spawns instead.
All tick commands I have are:
Summons lantern under specific conditions:
execute if entity @a[nbt={Inventory:[{Slot:101b,tag:{Enchantments:[{id:"minecraft:flame",lvl:1s}]}}]}] at @a[nbt={Inventory:[{Slot:101b,tag:{Enchantments:[{id:"minecraft:flame",lvl:1s}]}}]}] unless entity @e[type=armor_stand,nbt={Tags:["floatlantern"]},limit=1,distance=..2] run summon armor_stand ^.5 ^1 ^-.5 {Invulnerable:1b,Small:1b,ArmorItems:[{id:"air",Count:1},{id:"air",Count:1},{id:"air",Count:1},{id:"soul_lantern",Count:1}],NoGravity:1b,DisabledSlots:2096896,Invisible:1b,NoBasePlate:1b,Tags:["floatlantern"]}
Two cmnds check to remove lantern:
execute as @e[type=armor_stand,limit=1,nbt={Tags:["floatlantern"]}] at @e[type=armor_stand,limit=1,nbt={Tags:["floatlantern"]}] unless entity @a[nbt={Inventory:[{Slot:101b,tag:{Enchantments:[{id:"minecraft:flame",lvl:1s}]}}]},limit=1,distance=..2] run function dynlight:remove_light/kill_marker
execute as @e[type=armor_stand,limit=1,nbt={Tags:["floatlantern"]}] at @e[type=armor_stand,limit=1,nbt={Tags:["floatlantern"]}] unless entity @a[nbt={Inventory:[{Slot:101b,tag:{Enchantments:[{id:"minecraft:flame",lvl:1s}]}}]},limit=1,distance=..2] run kill @s
Checks to teleport lantern:
execute as @e[type=armor_stand,nbt={Tags:["floatlantern"]},limit=1] at @a[nbt={Inventory:[{Slot:101b,tag:{Enchantments:[{id:"minecraft:flame",lvl:1s}]}}]}] unless entity @e[type=armor_stand,nbt={Tags:["floatlantern"]},limit=1,distance=0..1] run tp @e[type=armor_stand,nbt={Tags:["floatlantern"]},limit=1] ^.5 ^1 ^-.5
Continue to help post