#effect is not giving

1 messages · Page 1 of 1 (latest)

gritty junco
#

i maked code like this but effects is ot giving


system.runInterval(() => {
  try {
    const entities = [
      ...world.getDimension(MinecraftDimensionTypes.overworld).getEntities(),
    ].filter((entity) => spawn.isOnLocation(entity.location));
    for (const entity of entities) {
      if (entity.typeId === "minecraft:player") {
        entity.addEffect("weakness", 40, {
          amplifier: 255,
          showParticles: false,
        });
      } else if (
        entity.typeId == "minecraft:item" &&
        new Area(globals.lobbyArea3, globals.lobbyArea2).isOnLocation(
          entity.location
        )
      )
        entity.kill();
      else entity.kill();
    }
  } catch (error) {
    console.warn(error);
  }
});

(Script api returns no error)

stable harborBOT
#
Debug Result

There are 4 errors in this [code](#1130197198550863963 message):

<repl>.js:6:26 - error TS2304: Cannot find name 'spawn'.

6     ].filter((entity) => spawn.isOnLocation(entity.location));
                           ~~~~~

``````ansi
<repl>.js:15:13 - error TS2304: Cannot find name 'Area'.

15         new Area(globals.lobbyArea3, globals.lobbyArea2).isOnLocation(
               ~~~~

``````ansi
<repl>.js:15:18 - error TS2304: Cannot find name 'globals'.

15         new Area(globals.lobbyArea3, globals.lobbyArea2).isOnLocation(
                    ~~~~~~~

``````ansi
<repl>.js:15:38 - error TS2304: Cannot find name 'globals'.

15         new Area(globals.lobbyArea3, globals.lobbyArea2).isOnLocation(
                                        ~~~~~~~

undone rune
#
for (const player of world.getAllPlayers()) {
     try {
      player.addEffect("weakness", 40, {
          amplifier: 255,
          showParticles: false,
      });
     } catch {}
}
#

you should use BlockVolumeUtils instead of the area js i sent you, is better and official

gritty junco
undone rune
#

#1067535608660107284 message