So far haven’t tried anything but change the variable a bit but didn’t work. Hopefully somebody can help me out here and I can learn something new today.
You’re trying to compare humanoid with an AttackZone. That’s not how it works.
A proper way of doing is just in the loop for the attacking enemy, have it check if the player is touching the Zone, and if they are, attack them, otherwise, stay still.
Also your thing would move to every player in the game rather than the closest one
I would highly recommend using Region3 that way you can detect the player that entered the zone and if they left, if they enter make the Enemy walk towards them, if not they go back to their original spot.
You could use the formula in the post to generate a Region3, and everytime it tries to move the enemy, check if that place’s character is in the region3 via FindPartsInRegion3, which returns a table of all the parts found, meaning you’d have to loop through that as well I believe
yeah, but how would i actually check if the player was in region3 because I tried to do that although it did not find the actual player but the other parts
That code only works once, hence why it wont work properly, put the while wait() do outside and do the FIndPartsINRegion3 code inside it when it has to see if a player is in the region when attacking.
We could discuss this more tomorrow if needed as it’s night time for me