I'm trying to clone an NPC have a follow script inside, but when I clone, it flying and didnt chase me, it flighting around and being stupid, it didnt chase anyone, anyone can fix this for me? Clone Script

local cloneBot = game.ServerStorage.Bot:Clone()
cloneBot.Name = "Bot"
cloneBot.Parent = game.Workspace
cloneBot.LowerTorso.Position = game.Workspace:WaitForChild("CurrentMap").Spawn.Position + Vector3.new(0,1,0)

Follow Script

function findNearestPlayer(Position)
	wait(0.3)
 	local List = game.Workspace:children()
 	local Torso = nil
 	local Distance = 200
 	local Temp = nil
 	local Human = nil
 	local Temp2 = nil
 	for x = 1, #List do
  		Temp2 = List[x]
  		if (Temp2.className == "Model") and (Temp2 ~= script.Parent) then
   			Temp = Temp2:findFirstChild("HumanoidRootPart")
   			Human = Temp2:findFirstChild("Humanoid")
   			if (Temp ~= nil) and (Human ~= nil) and (Human.Health > 0) then
    			if (Temp.Position - Position).magnitude < Distance then
     				Torso = Temp
     				Distance = (Temp.Position - Position).magnitude
    			end
   			end
 		end
 	end
	return Torso
end




while true do
 	local target = findNearestPlayer(script.Parent.HumanoidRootPart.Position)
 	if target ~= nil then
  		script.Parent.Humanoid:MoveTo(target.Position, target)
	end
end

NOTE : THERE IS NO ERROR

1 comment

0

This issue about this NPC is stupid