function movement.strafe()local g=(status:get("\099\117\114\114\101\110\116\084\097\114\103\101\116")).Position local V,S=myRoot.Position,nil local I=math.random(2)if I==1 then S=myRoot.CFrame.RightVector elseif I==2 then S=-myRoot.CFrame.RightVector end for g=1,10,1 do if not core.raycast(V,S*2)and core.raycast(V,Vector3.new(0,-7,0))then V+=S*2 else V+=S*-2 break end end local J,R=core.raycast(V,((status:get("\099\117\114\114\101\110\116\084\097\114\103\101\116")).Position-V).Unit*30)if R then if R.Instance:IsDescendantOf((status:get("\099\117\114\114\101\110\116\084\097\114\103\101\116")).Parent)then else V=myRoot.Position end V=myRoot.Position end return V end function checkDirection(g)local V=(status:get("\099\117\114\114\101\110\116\084\097\114\103\101\116")).Position local S=myRoot.Position local I=false for V=1,5,1 do if not core.raycast(S,g*1)and core.raycast(S,Vector3.new(0,-7,0))then S=S+g*1 else S=S+g*-1 break end if V==5 then I=true end end return I,S end function movement.retreat()local g,V=checkDirection(-((status:get("\099\117\114\114\101\110\116\084\097\114\103\101\116")).Position-myRoot.Position).Unit)if g then return V end g,V=checkDirection(myRoot.CFrame.RightVector)if g then return V end g,V=checkDirection(-myRoot.CFrame.RightVector)if g then return V end return myRoot.Position end function movement.slowAdvance()local g=(status:get("\099\117\114\114\101\110\116\084\097\114\103\101\116")).Position local V=myRoot.Position local S=30 repeat S-=1 if not core.raycast(V,(g-V).Unit*1)and core.raycast(V,Vector3.new(0,-7,0))then V=V+(g-V).Unit*1 else V=V+(g-V).Unit*-1 break end if S<=0 then break end until false return V end

function movement.strafe()
	local goalPos = status:get("currentTarget").Position
	local origin,dir = myRoot.Position,nil
	
	local action = math.random(2)
	if action == 1 then
		dir = myRoot.CFrame.RightVector
	elseif action == 2 then
		dir = -myRoot.CFrame.RightVector
	end
	
	for _=1,10 do
		if not core.raycast(origin,dir*2) and core.raycast(origin,Vector3.new(0,-7,0)) then
			origin += dir*2
		else
			origin += dir*-2
			break
		end
	end
	
	local _,result = core.raycast(origin,(status:get("currentTarget").Position - origin).Unit * 30)
	if result then
		if result.Instance:IsDescendantOf(status:get("currentTarget").Parent) then

		else

			origin = myRoot.Position
		end
		origin = myRoot.Position
	end
	
	return origin
end

function checkDirection(dir)
	local goalPos = status:get("currentTarget").Position
	local origin = myRoot.Position
	
	local success = false
	for i=1, 5 do
		if not core.raycast(origin,dir*1) and core.raycast(origin,Vector3.new(0,-7,0)) then
			origin = origin + dir*1
		else
			origin = origin + dir*-1
			break
		end
		
		if i == 5 then
			success = true
		end
	end
	
	return success,origin
end

function movement.retreat()
	
	--Check if we can retreat directly from the enemy.
	local result,pos = checkDirection(-(status:get("currentTarget").Position - myRoot.Position).Unit)
	if result then
		return pos
	end
	
	--Check if we can move away to the right.
	result,pos = checkDirection(myRoot.CFrame.RightVector)
	if result then
		return pos
	end
	
	--Check if can move away to the left.
	result,pos = checkDirection(-myRoot.CFrame.RightVector)
	if result then
		return pos
	end
	
	return myRoot.Position
end

function movement.slowAdvance()
	local goalPos = status:get("currentTarget").Position
	local origin = myRoot.Position
	
	local maxIterations = 30
	repeat
		maxIterations -= 1
		if not core.raycast(origin,(goalPos - origin).Unit*1) and core.raycast(origin,Vector3.new(0,-7,0)) then
			origin = origin + (goalPos - origin).Unit*1
		else
			origin = origin + (goalPos - origin).Unit*-1
			break
		end
		if maxIterations <= 0 then
			break
		end
	until false 
	
	return origin
end