This weird error.

  • So i have a problem. I recently got invaded by an NPC, and my attackers are supposed to spawn whenever there is a hostile creep in the room. However, all they do is spawn and they don't move. Can anyone help?

    var roleAttacker = {

    /** param {Creep} creep **/
    run: function (creep) {
        if( > 0) {
            var sources =;
            if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
                creep.moveTo(sources[0], {visualizePathStyle: {stroke: '#ffaa00'}});
        else {
            var hostile = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
            if(hostile) {
                if(creep.attack(hostile[0] == ERR_NOT_IN_RANGE) 

    } module.exports = roleAttacker

    I also got this weird error that doesn't tell me where my code error is, but just won't let my code run.

    [10:23:58][shard3]SyntaxError: Unexpected identifier [role.

  • Regarding your first problem: It seems that you are missing a closing parenthesis. creep.attack(hostile[0] == ERR_NOT_IN_RANGE should be creep.attack(hostile[0]) == ERR_NOT_IN_RANGE.

  • Ok thank you! I'll run it through in simulator mode and see whether it works.

  • Update: it didn't work. my creeps are still just spawning and not doing anything.