Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Stuck on codecombat level 6 game dev 2

# The player only needs to defeat some of the enemies.
game.spawnPlayerXY("guardian", 62, 25);

# Use game.addDefeatGoal(X) to allow the player to win
# after defeating X enemies! (In this case, X should be 4)
x = 4
unit = "gaurdian"
game.addDefeatGoal("guardian", "spawn", x)
enemy = unit.findNearestEnemy

while True:
    unit.attack(enemy)

I dont know what im doing wrong exactly can someone try this in their codecombat and see if it works?

// Use game.addDefeatGoal(X) to allow the player to win
// after defeating X enemies! (In this case, X should be 4)
game.addDefeatGoal(4);

You are only adding the goal, also you click on enemy when playing to attack them.