Npc getting stuck lolol

so uh this npc is supposed to follow and hit me but sometimes its like floating in the air fors ome reason idk
https://gyazo.com/5cd3fb81c2feaaba5d60859924328151

local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local PathFindingService = game:GetService("PathfindingService")
local ZoneModule = require(ServerStorage.Modules.Zone)
local DelinquentList = ServerStorage.Parts.NPCS.Delinquents
local Delinquents = script.Parent
local StunnedList = ServerStorage.PlayerList.Stunned

local OnHitAnims = {
	ReplicatedStorage.Animations.OnHit1,
	ReplicatedStorage.Animations.OnHit2,
	ReplicatedStorage.Animations.OnHit3,
	ReplicatedStorage.Animations.OnHit4,
}

local Animations = {
	["1"] = ReplicatedStorage.Animations.Tools["Normal Combat"].Hit1,
	["2"] = ReplicatedStorage.Animations.Tools["Normal Combat"].Hit2,
	["3"] = ReplicatedStorage.Animations.Tools["Normal Combat"].Hit3,
	["4"] = ReplicatedStorage.Animations.Tools["Normal Combat"].Hit4,
	["5"] = ReplicatedStorage.Animations.Tools["Normal Combat"].Hit5,
}

local OnBlockAnim = ReplicatedStorage.Animations.Blocks["Normal OnBlock"]
local BlockBreak = ReplicatedStorage.Animations.BlockBreak
local BlockingList = ServerStorage.PlayerList.Blocking
local IsBlocking = ReplicatedStorage.RemoteFunctions.IsBlocking
local StunnedList = ServerStorage.PlayerList.Stunned
local Tag = require(ServerStorage.Modules.Tag)
local StunModule = require(ServerStorage.Modules.Stun)
local DamageIndicator = require(ServerStorage.Modules.DamageIndicator)
local DebrisService = game:GetService("Debris")
local SkinOverlay = require(ServerStorage.Modules.SkinOverlay)

for i,v in pairs(DelinquentList:GetChildren()) do
	if v:IsA("Model") then
		v:Clone().Parent = Delinquents
		
		
	end
end

while true do
	wait(0.2)
	for i,v in pairs(Delinquents:GetChildren()) do
		if v:IsA("Model") then
			if v.Humanoid.Health > 0 then
				
				local Cooldown = v.Cooldown
				local Sprintanim = ReplicatedStorage.Animations.Sprint
				local Sprintanimtrack = v.Humanoid:LoadAnimation(Sprintanim)
				local OwnCharacter = v.Name
				local Range = v.Range
				local Hitbox2 = v.Hitbox2
				local ClosestPart = nil

				for i,v in pairs(game.workspace:GetPartsInPart(Range)) do
					if v:IsA("Part") and v.Name == "Hitbox" then
						if Players:FindFirstChild(v.Parent.Name) then
							if ClosestPart ~= nil then
								if v.Parent.HumanoidRootPart.Position < ClosestPart then
									ClosestPart = v.Parent.HumanoidRootPart
								end
							else
								ClosestPart = v.Parent.HumanoidRootPart
							end
						end
					end
				end
				
				print(Cooldown.Value)
					if ClosestPart ~= nil and not StunnedList:FindFirstChild(v.Name) then -- found something and didnt get stunned
						
						v.Humanoid:MoveTo(ClosestPart.Position,ClosestPart)
						Sprintanimtrack:Play()
						v.Humanoid.MoveToFinished:Wait()
						Sprintanimtrack:Stop()

					if not StunnedList:FindFirstChild(v.Name) and Cooldown.Value == false then
						local RandomNumber2 = math.random(1,5)
						local AnimTracks = {
							["Hit1"] = v.Humanoid.Animator:LoadAnimation(Animations["1"]),
							["Hit2"] = v.Humanoid.Animator:LoadAnimation(Animations["2"]),
							["Hit3"] = v.Humanoid.Animator:LoadAnimation(Animations["3"]),
							["Hit4"] = v.Humanoid.Animator:LoadAnimation(Animations["4"]),
							["Hit5"] = v.Humanoid.Animator:LoadAnimation(Animations["5"]),
						}
						local Target = nil
						
						
						local cooldowncoroutine = coroutine.wrap(function()
							wait(3)
							Cooldown.Value = false
						end)
						
							Cooldown.Value = true
							cooldowncoroutine()
						
							AnimTracks["Hit" .. RandomNumber2]:Play()
							for i,v in pairs(game.workspace:GetPartsInPart(Hitbox2)) do
								if v:IsA("Part") and v.Name == "Hitbox" then
									if Players:FindFirstChild(v.Parent.Name) then -- if player
										Target = v.Parent.HumanoidRootPart
									end
								end
							end
							
						if Target ~= nil and not Target.Parent:FindFirstChild("ForceField") then
						
							local OnHitEvent = ReplicatedStorage.RemoteEvents.Client.OnHit
							local TargetPlayer = Players:FindFirstChild(Target.Parent.Name)
							local RandomNumber = math.random(1,4)
							local OnBlockAnimTrack = Target.Parent.Humanoid:LoadAnimation(OnBlockAnim)
							local OnHitAnimTrack = Target.Parent.Humanoid:LoadAnimation(OnHitAnims[RandomNumber])
							local KnockBack = Instance.new("BodyVelocity")
							KnockBack.MaxForce = Vector3.new(500000,500000,500000)
							KnockBack.Parent = Target

							Tag.Function(Target.Parent,TargetPlayer)

							v.Humanoid.WalkSpeed = 10

							if BlockingList:FindFirstChild(Target.Parent.Name) then
								if TargetPlayer then
									if IsBlocking:InvokeClient(TargetPlayer) == true then
										SkinOverlay.Blocked(Target.Parent)
										Target.Parent.Humanoid.Health -= 6
										StunModule.Function(0.8,Target.Parent)
										OnBlockAnimTrack:Play()
									elseif IsBlocking:InvokeClient(TargetPlayer) == false then
										BlockingList[Target.Parent.Name]:Destroy()

										SkinOverlay.Hit(Target.Parent)
										Target.Parent.Humanoid.Health -= 10
										DamageIndicator.Function(Target.Parent,10)
										StunModule.Function(0.8,Target.Parent)
										OnHitAnimTrack:Play()
									end
								else
									SkinOverlay.Blocked(Target.Parent)
									Target.Parent.Humanoid.Health -= 6
									StunModule.Function(0.8,Target.Parent)
									OnBlockAnimTrack:Play()
								end
							else
								SkinOverlay.Hit(Target.Parent)
								Target.Parent.Humanoid.Health -= 10
								DamageIndicator.Function(Target.Parent,10)
								StunModule.Function(0.8,Target.Parent)
								OnHitAnimTrack:Play()
							end

							OnHitEvent:FireClient(TargetPlayer)

							KnockBack.Velocity = v.HumanoidRootPart.CFrame.LookVector * 10
							local KnockBackCoroutine = coroutine.wrap(function()
								wait(0.15)
								KnockBack:Destroy()
							end)

							KnockBackCoroutine()

							wait(0.1)
							v.Humanoid.WalkSpeed = 20
							end
						end
					else
						Sprintanimtrack:Stop()
					end
			end
		end
	end
	
end

image

Can you pinpoint the area in the code which needs fixing?

nothing is erroring in the output it just gets stuck randomly

You mentioned it was floating, try fixing the HipHeight property of its humanoid.