#Add Tag Not Working

1 messages · Page 1 of 1 (latest)

faint zodiac
#
import {world, system} from "@minecraft/server"

world.afterEvents.itemUse.subscribe(({itemStack, player}) => {
    
    player.addTag(`itemUse:${itemStack.typeId}`)

    if (itemStack.nameTag) player.addTag(`itemUseName:${itemStack.nameTag}`)

    system.run(() => {

        player.runCommandAsync(`tag @s remove itemUse:${itemStack.typeId}`)

        player.runCommandAsync(`tag @s remove itemUseName:${itemStack.nameTag}`)

    })

})

world.afterEvents.itemUseOn.subscribe(({itemStack, player}) => {

    player.addTag(`itemUseOn:${itemStack.typeId}`)

    if (itemStack.nameTag) player.addTag(`itemUseName:${itemStack.nameTag}`)

    system.run(() => {

        player.runCommandAsync(`tag @s remove itemUseOn:${itemStack.typeId}`)

        player.runCommandAsync(`tag @s remove itemUseName:${itemStack.nameTag}`)

    })

})
#

im really confused and i dont know how to fix this issue

ionic arch
#

You just put itemStack.nameTag

faint zodiac
#

a

ionic arch
#

also, it's not a player it's source

faint zodiac
#

e

#

wait

#

the thing you want me to change

#

is on line 7

#

source.addTag(itemUse:${itemStack.typeId})

#

thats line 5

ionic arch
# faint zodiac e
world.afterEvents.itemUse.subscribe(({ itemStack, source }) => {
   if (itemStack) {
      system.run(() => {
         source.addTag(`itemUse:${itemStack.typeId}`);
          if (itemStack.nameTag) {
             source.addTag(`itemUse:${itemStack.nameTag}`);
             system.runTimeout(() => {
                source.removeTag(`itemUse:${itemStack.nameTag}`);
             }, 1);
          });
      });
      system.runTimeout(() => {
         source.removeTag(`itemUse:${itemStack.typeId}`);
      }, 1);
   }
});```
faint zodiac
#

o