swords generally leave a tag, a ValueInstance, in the character that they damage. This is normally used by leaderboard systems to determine who killed a character. You can use this to determine who attacked the NPC. Then, you can using the pathfinding service to try and walk towards the player while slashing. This is the most common method used in RPG games.
To get more advanced you could integrate my new sword fighting AI into your game. I described it here:
It doesn’t do any pathfinding, jumping, or slashing yet though and you would need to modify the movement to work with your NPC models / system. Shouldn’t be too hard. I also never got around to serializing the Q-table but a quick call to the HttpService EncodeJSON / DecodeJSON should handle that well. This would be a very deadly AI to get near once fully trained!