--[[To use this script simply place the walk points where you want 
and the NPC will follow them.  will follow them first You can create as many points as needed
simply just duplicate a point and name it the next number in your line.

Note: DO NOT TOUCH ANYTHING ELSE IN THIS SCRIPT WITHOUT ASKING ME ~BigBoss(Raildex)
]]

local waitTime = 5 --This is the only thing you will need to change, it is the time he spends at the end of the points before going back the other way.

local waitPoint = script.Parent.Parent.WalkPoints:WaitForChild("1")
local points = script.Parent.Parent.WalkPoints:GetChildren()

script.Parent.Head.Weld.Part0 = script.Parent.Head
script.Parent.Head.Weld.Part1 = script.Parent.FakeHead
script.Parent.Torso["Neck"].Part1 = script.Parent.Head
script.Parent.Torso["Neck"].Part0 = script.Parent.Torso

script.Parent.Torso["Left Hip"].Part1 = script.Parent["Left Leg"]
script.Parent.Torso["Left Hip"].Part0 = script.Parent.Torso

script.Parent.Torso["Right Hip"].Part1 = script.Parent["Right Leg"]
script.Parent.Torso["Right Hip"].Part0 = script.Parent.Torso

script.Parent.Torso["Left Shoulder"].Part1 = script.Parent["Left Arm"]
script.Parent.Torso["Left Shoulder"].Part0 = script.Parent.Torso

script.Parent.Torso["Right Shoulder"].Part1 = script.Parent["Right Arm"]
script.Parent.Torso["Right Shoulder"].Part0 = script.Parent.Torso

function WeldClothes()
	local children = script.Parent:GetChildren()
	for i = 1, #children do
		if children[i].ClassName == 'Part' and children[i].Name ~= 'FakeHead' then
			local clothes = children[i].Clothes:GetChildren()
			for j = 1, #clothes do
				local W = Instance.new('Weld')
				W.Part0 = children[i]
				W.Part1 = clothes[j]
				local CJ = CFrame.new(children[i].Position)
				local C0 = children[i].CFrame:inverse()*CJ
				local C1 = clothes[j].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = children[i]
				clothes[j].Anchored = false
				clothes[j].CanCollide = false
				--[[
				local Y = Instance.new("Weld")
				Y.Part0 = hit
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0]]
			end
		end
	end
end
WeldClothes()

script.Parent.Torso.Touched:connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") then
		script.Parent.Torso.Anchored = true
		wait(.5)
		script.Parent.Torso.Anchored = false
	end
end)
wait(30)
while true do
	for i=1,#points do
		repeat
			script.Parent.Humanoid:MoveTo(script.Parent.Parent.WalkPoints[i].Position)
			wait(.5)
		until (script.Parent.Torso.Position - script.Parent.Parent.WalkPoints[i].Position).magnitude <= 4
	end
	wait(waitTime)
	for i=1,#points do
		repeat
			script.Parent.Humanoid:MoveTo(script.Parent.Parent.WalkPoints[#points+1-i].Position)
			wait(.5)
		until (script.Parent.Torso.Position - script.Parent.Parent.WalkPoints[#points+1-i].Position).magnitude <= 4
	end
	wait(waitTime)
end
