March 19, 2021, 7:24pm
Hey there guys. Basically I’ve been trying to make it so that an enemy comes after you after you enter It’s attack zone. Although this hasn’t worked.
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.
The only thing I see wrong is this line
if humanoid == xyx then
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
March 19, 2021, 7:28pm
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.
March 19, 2021, 7:33pm
How would I use Region3 here though. I have never used it before so maybe try putting code and like explaining what it does?
I would recommend reading about it and how you could try to add it
March 19, 2021, 8:39pm
I went on there, and I got the basic idea of it I guess but I have no idea what to do with it.
March 19, 2021, 8:39pm
I did try using it but still didn’t work for you to know.
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
March 19, 2021, 8:42pm
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
How did you code look like when trying to use FindPartsInRegion3?
March 19, 2021, 9:04pm
Sorry for late response, went to get lunch.
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