Sarven Shepherd Bug w/ Lua & Python

So when I was playing this level I did everything correctly except when ran, the hero just stopped in the center. I have done everything asked in the level. But all my hero does is instead of detecting the enemys that are attacking him, he just repeatetly goes to (40, 32). I wondered if this was a bug with Lua because most levels are in JS or Python when I boot them up. So I opened the level in Python and had the exact same experience.

Here is the Lua code I used:

-- Use while loops to pick out the ogre

while true do
    local enemies = self:findEnemies()
    local enemyIndex = 1

    -- Wrap this logic in a while loop to attack all enemies.
    while true do
        local enemy = enemies[enemyIndex]
        -- "~=" means "not equal to."
        if enemy.type ~= "sand-yak" then
            -- While the enemy's health is greater than 0, attack it!
            while enemy.health > 0 do
                hero:attack(enemy)
            end
        end
        
    -- Between waves, move back to the center.
    hero:moveXY(40, 32)
    end
end

What level name is it?

The name of the level is in the title of the post.