--Made by Haustier and Luckymaxer

local humanoid = script.Parent.Humanoid
local head = script.Parent.Head
local walkDistance = 20 --radius
local detectionDistance = 20

function walkBackAndForth()
	while wait() do
		local targetPos = head.CFrame * CFrame.new(0, 0, -walkDistance)
		targetPos = Vector3.new(targetPos.X, targetPos.Y, targetPos.Z)
		humanoid:MoveTo(targetPos)
		local counter = 0
		repeat
			wait()
			counter = counter + 1
			if counter >= 100 then
				break
			end
		until (head.Position - targetPos).magnitude <= 2
		walkDistance = -walkDistance
	end
end

walkBackAndForth()
