Found a protecial bug please help ...... Game dev 2 4. Guard duty

Hi,
This is my code for level 4. Guard Duty.
// Add a soldier to the level to prevent ogres from crossing the path.
// Command the soldier using an event handler function.
function soldierLogic() {
game.spawnHeroXY(soldier, 42, 48);
// Fill in the code for the soldier’s actions here.
// Remember to use ‘soldier’ instead of ‘hero’!
while (true) {
var enemy = soldier.findNearestEnemy();
if (enemy) {
solider.attack(enemy);
} else
solider;
hero.moveXY(42, 48);
}
}
// This assigns your spawned unit to the soldier variable.
var soldier = game.spawnXY(“soldier”, 42, 48);
// This says to run the soldierLogic function when the soldier is spawned.
soldier.on(“spawn”, soldierLogic);
My freinds and I have spent 2 lessons (2h 45 min) trying to figure this out… We think this is a bug
Thanks

1 Like

Please format your code according to the CodeCombat FAQ.

2 Likes

} else
solider;

Is that the error? Also, the number of brackets do not match up

1 Like