Simple NPC script not working

I am making a simple npc, but the script isnt working. One more quick question, what would be the most lag reducing way to run this, beausce I am going to have a lot of them. Here is the script:

local enhum = script.Parent.Humanoid
local walk = enhum.Walk
local loadwalk = enhum:LoadAnimation(walk)
local attack = enhum.Attack
local loadattack = enhum:LoadAnimation(attack)
while wait() do 
for i, v in pairs(game.Players:GetChildren()) do
		local char = game.Workspace:WaitForChild(v.Name)
		function attack()
			if (script.Parent.HumanoidRootPart.Position - char.HumanoidRootPart.Position).magnitude < 6 then
				if char.Parent ~= nil then
					loadattack:Play()
					char.Parent.Humanoid.Health = char.Parent.Humanoid.Health - 5
				end
				wait(0.4)
			end
		end


		loadwalk:Play()
		attack()
		enhum.MoveToFinished:Wait()
		loadwalk:Stop()
	end
	end
local players = game:GetService("Players")
function died()
	local db = false
	script.Parent.HitPart.Touched:Connect(function(otherpart)
		if db == false then
			if otherpart.Name == "Handle" then
				db = true
				local player = players:GetPlayerFromCharacter(otherpart.Parent.Parent)
				print(player)
				player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1	
			end
			if otherpart.Parent:FindFirstChild("Humanoid") and otherpart.Parent:FindFirstChild("Health") then
				db = true
				local player = players:GetPlayerFromCharacter(otherpart.Parent)
				player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1
			end
		end
	end)
	loadwalk:Stop()
	local torso = script.Parent.Torso
	torso:Destroy()
	wait(5)
	script.Parent:Destroy() 
end

enhum.Died:Connect(died)

everything in the model has anchor off and the humanoidrootpart has cancolide off. Im not sure if it matters but I have another group in it, because I cant union something.

What you mean by this? is this connected to your NPC?

Also, are you getting any errors in output?

There are no errors, and the walking animation half runs, I made something in blender, but uploaded it as multiple parts so I had to model it. That model is directly under the npc.

How is that model welded or motor6d to your NPC?

Also, explain what happens… does your NPC just not move anywhere?

Yes, everything is welded to the npc, he doesnt move anywhere he just half plays the walk animation.

This event fires when the Humanoid finishes walking to a goal declared by the Humanoid.WalkToPoint and Humanoid.WalkToPart properties.

I dont believe you have scripted any MoveTo function for the NPC to follow… you have dealt with attack and died functions, but have not directed the NPC to move anywhere, but declared a MoveToFinished. As i copied from Roblox docs, a MoveToFinished goal has to be declared through WalkToPoint or WalkToPart… i even think you would be ok just declaring a MoveTo property and setting a Vector position for it to move to.