# \[SOLVED\] Backwoods forest : The one wizard challenge help

**URL:** <https://discourse.codecombat.com/t/solved-backwoods-forest-the-one-wizard-challenge-help/15064>\
**Category:** Adventurer\
**Created:** [June 27, 2018, 6:42pm UTC](https://discourse.codecombat.com/t/solved-backwoods-forest-the-one-wizard-challenge-help/15064 "2018-06-27T18:42:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chico114](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@chico114](https://discourse.codecombat.com/u/chico114)\
**Post date:** [June 27, 2018, 6:42pm UTC](https://discourse.codecombat.com/t/solved-backwoods-forest-the-one-wizard-challenge-help/15064/1 "2018-06-27T18:42:11Z")

</div>

So i was tinkering on this level a bit until i find a way to fix the level that doesn’t let me load and i decided to play this level. I can easily do one or two tasks but im trying to get the other bonus but i ran into a problem that i dont understand.  
Here is the code, i know it can be improved a bit but i just want to know whats causing this error i will give screenshots with the code and I will place it in text:

 ![Screenshot_350](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/7/74e5dc0bf0df28d4274997a8a2dc8567e6d29d2c.png)

You can see the error that its giving me, now here is the code in text:

```python
while true do
    local target = hero:findNearestEnemy()
    
if target and hero:canCast("chain-lightning", target) then
    hero:cast("chain-lightning", target)
    
    elseif target and target.type == "scout" or target.type == "ogre" or target.type == "catapult" and hero:canCast("lightning-bolt", target) then
        hero:cast("lightning-bolt", target)
    elseif target then
        hero:attack(target)
    
end

end

```

---

<div class="post-metadata">

**Author:** ![Seojin\_Roy\_Lee](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/seojin_roy_lee/32/23539_2.png) [@Seojin\_Roy\_Lee](https://discourse.codecombat.com/u/Seojin_Roy_Lee)\
**Post date:** [June 27, 2018, 8:40pm UTC](https://discourse.codecombat.com/t/solved-backwoods-forest-the-one-wizard-challenge-help/15064/2 "2018-06-27T20:40:25Z")

</div>

> [@chico114](#):
>
> `hero:canCast("chain-lightning", target)`

you don’t need to add the target in `hero:canCast()`.

---

<div class="post-metadata">

**Author:** ![chico114](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@chico114](https://discourse.codecombat.com/u/chico114)\
**Post date:** [June 27, 2018, 9:10pm UTC](https://discourse.codecombat.com/t/solved-backwoods-forest-the-one-wizard-challenge-help/15064/3 "2018-06-27T21:10:11Z")

</div>

really ? i think i clicked tab and it pre wrote it like this.

Edit: I fixed it as you said it was wrong but it still giving the error

 ![Screenshot_351](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/4/4ec26ac912cee7a158b4a20c178d00dfbdc60b61.png)

---

<div class="post-metadata">

**Author:** ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)\
**Post date:** [June 28, 2018, 7:22am UTC](https://discourse.codecombat.com/t/solved-backwoods-forest-the-one-wizard-challenge-help/15064/4 "2018-06-28T07:22:20Z")

</div>

The `if` for `canCast()` is not in the loop

---

<div class="post-metadata">

**Author:** ![chico114](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@chico114](https://discourse.codecombat.com/u/chico114)\
**Post date:** [June 28, 2018, 10:18am UTC](https://discourse.codecombat.com/t/solved-backwoods-forest-the-one-wizard-challenge-help/15064/5 "2018-06-28T10:18:48Z")

</div>

Its not in the loop ? Can you explain a bit why. Nvm i got it i was looking for something that didnt exist, now i just gotta understand how im gonna kill those bonus 44 orcs

---

<div class="post-metadata">

**Author:** ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)\
**Post date:** [June 28, 2018, 10:49am UTC](https://discourse.codecombat.com/t/solved-backwoods-forest-the-one-wizard-challenge-help/15064/6 "2018-06-28T10:49:47Z")

</div>

The _**if target and hero:canCast(“chain-lightning”, target)**_ is in the loop between _ **do -\> end** _  
**_if hero.canCast(“chain-lightning”):_**  
**_if hero.isReady(“chain-lightning”):_**  
are equivalent  
_ **chain-lightning** _ is a weapon of mass destruction and somehow must be ensured we target only living beings…
