NPC Follow problem

I’m trying to make the NPC Follow the player, but when the distance between the NPC and the player becomes short the NPC starts shuddering.

here is the code

local npc = script.Parent
local humanoid = npc.Humanoid
local HRP = npc.HumanoidRootPart
local runSpeed = 22
local followDistance = 60
local attackDistance = 4

function Follow(hrp)
	humanoid.WalkSpeed = runSpeed --make npc run
	humanoid.WalkToPoint= hrp.Position
end

function Repeat2(npc, crrPlr)
	local currentPlayer = crrPlr -- the player character that the NPC should follow
	repeat
		local dis = (currentPlayer.HumanoidRootPart.Position - HRP.Position).magnitude -- calculate distance bteween the npc and the spoted player
		if dis < followDistance then

			--if the target is not in the attack dis then follow him
			spawn(function()
				if dis >= attackDistance then 
					Follow(currentPlayer.HumanoidRootPart)
				else
					npc.Humanoid:MoveTo(npc.HumanoidRootPart.Position) --stop the npc from moving
				end
			end)
		end
		wait()
	until currentPlayer.Humanoid.Health <= 0 or dis > followDistance or game.Players:FindFirstChild(currentPlayer.Name) == nil
end

Change the until to

until currentPlayer.Humanoid.Health <= 0 or dis < followDistance or game.Players:FindFirstChild(currentPlayer.Name) == nil

The greater than should’ve been a less than between the dis and followDistance

that way the npc will never follow the player
its 60 … the followDistance is the max distance that can be between the npc and player he is following

Maybe try changing the attack distance/ making the >= just >

its not working still the same

Don’t you need to script the attack part? I just noticed you don’t have that part in the video.