#snowball giving weakness on hit

1 messages · Page 1 of 1 (latest)

plain folio
#

Can someone help me get this script working?

import { world, EffectTypes } from "@minecraft/server";

world.afterEvents.projectileHitEntity.subscribe(event => {
const { projectile, entityHit } = event;

if (projectile.id === "minecraft:snowball") {
    entityHit.addEffect(EffectTypes.weakness, 200, 1);
}

});

This is what I have so far, no idea if any of it is even right

bitter hawkBOT
#
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1250954624727257170 message).
You can either send the script in code block highlighted in JS format:

​`​`​`js
world.sendMessage("Hello World");
​`​`​`

Or Send an attachment end in .js to debug the file.

distant parcel
#
import { world } from "@minecraft/server";

world.afterEvents.projectileHitEntity.subscribe(event => {
    const { projectile, getEntityHit } = event;

    if (projectile.typeId !== "minecraft:snowball") return;
    
    getEntityHit().entity?.addEffect('weakness', 200,{amplifier:1});
});