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)