Making a NPC that chases and attacks you

What do you want to achieve?
I want to make an NPC that chases you when you get near it, and it attacks you and has animations

What is the issue?
I’m not really sure what to start with. I’m not really a scripter, so I have trouble with knowing how to start it.

What solutions have you tried so far?
I have looked up other Dev Forum Posts, and YouTube videos, but nothing is appearing helpful to me.

I’m not asking anyone to create a whole script for me, just to help with what key points I need to add to make it all work.

The character is an Orc, from Lord of the Rings. I am trying to make it that when you are near it, it chases you, and it has a sword out. Then once it touches you or gets in a certain distance, it attacks you with a sword. Thank you everyone!

1 Like

Ideally use pathfinding so the NPC won’t get stuck behind objects.
Use magnitude to figure out how close the NPC is to the player. When the player is within a specified range then play the attack animation.

Edit: Wrong link mb

1 Like

Ideally, pathfinding should only be used when the npc has obstacles. Through casting a ray from the humanoidroot part or head and determining. If there isn’t just use normal Humanoid:MoveTo(), else use pathfinding to the nearest player.

1 Like

Impossible, there’s so many free models and videos youtube on how to make an AI that chases you or does anything

2 Likes

I dont use free models, never will. YouTube videos are always 40 minutes, when in reality, if I just knew the key details, I could make it, ya know?

I never said you should use free models, you have to look at their code and learn from it