NPC wont chase and attack closest player

Im gonna leave the game file here for anybody who has the time to take a look at it and try to see whats going on. ive tried multiple methods and none of work. Any help is appreciated.

the enemy is supposed to chase and attack me when i get in range but for some reason it’s not working.

NPC.rbxl (110.6 KB)

are you talking about the wolf or the zombie?

The zombie. I have the wolf anchored so it cant move for now.

you were checking if health.Value > 0 to make the main behavior loop, but in the stats folder of the zombie, the health value was set as 0 so the loop to find the closest player wasnt running.

also i recommend making the variable local closestPlayer = nil on the top of the script instead inside the loop, and making something to make the npc stop the random walking while it is in chasing mode.

Wow. Had no idea I had the value set to 0. That explains a lot. I’ll make the changes tomorrow and see how it goes. I also might remove the wall script or implement it with the main script if I can. Thanks for the help! I’ll let you know how it goes tomorrow.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.