Why are NPC followers sticking so close to me?

I’m working on a party member/NPC follower system for an RPG game I want to make, but I’m running into a small issue; when following the player, instead of staying a reasonable distance away as they should, they just move into the player’s humanoidrootpart’s position. If i’m lucky, it’ll work fine for a little bit, but then the NPCs just glitch out and do the error (which just happens naturally most of the time). Here’s some footage of the system working fine at first, then at around 0:25 the NPC just keeps walking into my character, ignoring the 3.5 stud “stop distance”

This is my code:

— the variables used in the functions
image

— the functions that make the thing work


what can I do?