#Is this a error, if it is, how to fix it ?

1 messages · Page 1 of 1 (latest)

jade jungle
#

Code works fine but when i break a block it shows that

#

[Scripting][error]-TypeError: cannot read property 'typeId' of undefined at <anonymous> (enchant_shop.js:37)

meager pebble
#

That because your if still run. Use ? before typeId

world.events.entityHit.subscribe(({entity, hitEntity}) => {
  if (hitEntity?.typeId == "npc:blacksmith") {
      es(entity)
  }
});