-- Module 4

function NpcModule.CalculeWalk(NPC, Range, MinVector, MaxVector, Minrange)
	local MinRange = 0
	
	if Minrange == nil then
		MinRange = 1.7
	else
	   MinRange = Minrange
	end
	
	-- Calcules	
	local X = math.random(-(Range), Range)
	local Z = math.random(-(Range), Range)
	
	if X < (Range/MinRange) and X >= 0 then
		X = Range/MinRange
	elseif X > (-Range/MinRange) and X < 0 then
		X = -Range/MinRange
	end
	
	if Z < (Range/MinRange) and Z >= 0 then
		Z = Range/MinRange
	elseif Z > (-Range/MinRange) and Z < 0 then
		Z = -Range/MinRange
	end

	X = NPC.PrimaryPart.Position.X + X
	Z = NPC.PrimaryPart.Position.Z + Z
	
	if MinVector ~= nil or MaxVector ~= nil then
		if X < MinVector.X then
			X = MinVector.X
		elseif X > MaxVector.X then
			X = MaxVector.X
		end

		if Z < MinVector.Z then
			Z = MinVector.Z
		elseif Z > MaxVector.Z then
			Z = MaxVector.Z
		end
	end

	local Pos = Vector3.new(X, NpcModule.RayY(X,Z,NPC) , Z)
	return Pos
end



