Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

I need help with my code


My troops attack everyone even though I said only brawler


Your OR: ||
should be an AND: &&
as such:
enemy && enemy.type == "brawler" && hero.distanceTo(enemy) < 50

As it reads right now, you’re saying if it’s a brawler or it’s ANYTHING within 50 units of the player, say “fire”


Thanks for your help, I already fixed, sorry for keeping it up


No problem. Glad you fixed it!


Can yu help me here?


That code works fine for me, but I have about 3x more health. I’ll try it with less in a moment.

What’s the problem you’re having with it?

My bad. You have an extra curly brace right under hero.attack(enemy);


He doesn’t attack all the enemies


Ah, I see it now. Edited my post.


It’s not extra look at screenshot


You’re right, but it should be placed underneath hero.move(item.pos);


Thanks I got it :boy:


I gotta go, bye, oh and if you wanna join clan, here is the link
we need people like you.