# Loop Error in Lua

**URL:** <https://discourse.codecombat.com/t/loop-error-in-lua/5475>\
**Category:** Bugs\
**Created:** [October 29, 2015, 4:23pm UTC](https://discourse.codecombat.com/t/loop-error-in-lua/5475 "2015-10-29T16:23:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixelwolf](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pixelwolf](https://discourse.codecombat.com/u/pixelwolf)\
**Post date:** [October 29, 2015, 4:23pm UTC](https://discourse.codecombat.com/t/loop-error-in-lua/5475/1 "2015-10-29T16:23:18Z")

</div>

In the duelling grounds level, I tried to make a loop like it said. But it gave me this:  
“Found an expression but expected a statement: while”. I tried reloading to the default and clicking “loop” under Programmaticon II. It still gave me the error. This is my code:

```
loop
    -- Nothing in here
end

```

I need help!  
@nick

---

<div class="post-metadata">

**Author:** ![4thkorean](https://avatars.discourse-cdn.com/v4/letter/4/94ad74/32.png) [@4thkorean](https://discourse.codecombat.com/u/4thkorean)\
**Post date:** [October 30, 2015, 8:13pm UTC](https://discourse.codecombat.com/t/loop-error-in-lua/5475/2 "2015-10-30T20:13:30Z")

</div>

So the sum total of your code looks something like this?

```python
--Use a loop to help defeat the enemy!

loop

end

```

With nothing else?

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [November 2, 2015, 5:30pm UTC](https://discourse.codecombat.com/t/loop-error-in-lua/5475/3 "2015-11-02T17:30:25Z")

</div>

Does it work if you put some statements in there? Like this:

```python
loop
    local enemy = self:findNearestEnemy()
    if enemy then
        self:attack(enemy)
    end
end

```

---

<div class="post-metadata">

**Author:** ![pixelwolf](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pixelwolf](https://discourse.codecombat.com/u/pixelwolf)\
**Post date:** [November 3, 2015, 2:01pm UTC](https://discourse.codecombat.com/t/loop-error-in-lua/5475/4 "2015-11-03T14:01:42Z")

</div>

I did, when there are no errors in the code inside it(nothing incomplete) it goes back to the found an expression thing! Even worse: I can’t change the language anymore!

---

<div class="post-metadata">

**Author:** ![pixelwolf](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pixelwolf](https://discourse.codecombat.com/u/pixelwolf)\
**Post date:** [November 3, 2015, 2:02pm UTC](https://discourse.codecombat.com/t/loop-error-in-lua/5475/5 "2015-11-03T14:02:38Z")

</div>

Yep, I added stuff and the error won’t go away.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [November 3, 2015, 2:10pm UTC](https://discourse.codecombat.com/t/loop-error-in-lua/5475/6 "2015-11-03T14:10:11Z")

</div>

I’ve got it on the bug list, we’ll get it soon. Thanks!
