I been trying to get my hero to find the nearest enemy to defeat it but it keep saying “line 7; Type Error: cannot read property “target” of undefined.”
// The player only needs to defeat some of the enemies.
game.spawnHeroXY(“goliath”, 62, 25);
// Use game.addDefeatGoal(X) to allow the player to win
// after defeating X enemies! (In this case, X should be 4)
game.addDefeatGoal(4);
var hero = hero.target; (this is line 7)
var enemy = hero.findNearestEnemy;
if (enemy)
hero.attackEnemy();