Unhandled error

I am doing the final level of HoC and whenever I do:

game.setActionFor("shaman", "spawn", function (event) {
    while (true) event.target.attack(hero);
});
game.spawnXY("shaman", 40, 50);
const hero = game.spawnPlayerXY("guardian", 40, 35);
while (true) {
    let missile = hero.findNearest(hero.findEnemyMissiles());
    if (missile) {
        let dir = Vector.subtract(missile.pos, hero.pos);
        hero.reflect(dir);
    }
}

It gives me the error: “Unhandled error: ReferenceError: act is not defined”.
@staff

Which line is the one with error?

It doesn’t say any line, since it’s an unhandled error. But I’m guessing it’s from the reflect() function.

Maybe remove the (true) part in line 2 (I don’t know much about javascript)

I’m sure that isn’t the error.

You can just try @moonwatcher348

It would just give me another error.

1 Like

I have over 2 years of experience with JavaScript, so I am sure.

1 Like

Then that might mean you know the error

No, this is an error that only exists in codecombat, and I don’t have much experience with codecombat.

Maybe you should check if shaman exists

just guessing (I don’t know javascript) hero should be defined before this line:

1 Like

Hero is already defined @Aya

I know, but it should be in a different order (probably), so that it can exist

I think is is defined already

1 Like

I think this is the part with error