Need help with Village Guard(LUA)

Hello,
I’m a newbie coder I am currently in Village Guard because it says I have an error "end expected (to close if at 19:1) at 19:1
This is the code I have (LUA)

-- Patrol the village entrances.
-- If you find an enemy, attack it.
loop
    local leftEnemy = self:findNearestEnemy()
    if leftEnemy then
        self:attack(leftEnemy)
        self:attack(leftEnemy)
    end
    -- Now move to the right entrance.
    -- Use "if" to attack if there is an enemy.\
    loop
        self:moveXY(60, 31)
        local rightEnemy = self:findNearestEnemy()
        if rightEnemy then
            self.attack(rightEnemy)
            end
    end

Hello, Vault_Boy, and welcome. Please read the FAQ before you post again, so you can learn how to format your code properly. I’ve done it for you this time, but do so yourself in the future.

You shouldn’t have two loops within each other. Just have one loop doing all your commands.

You want to be patrolling the points even if there is no enemy. Don’t forget to move to the left point as well as the right.