local function b(b,H,J)local Y=math.noise((b*Configuration.Frequency.Value)/10,(H*Configuration.Frequency.Value)/10,J)*(Random.new()):NextNumber(19.5,20)return Y end local function H(b,H,J)local Y=J:FindFirstChild(H.X..("\044 "..H.Z))if Y then print("\101\120\105\115\116\105\110\103")else local Y=Instance.new("\080\097\114\116")Y.Parent=J Y.Name=H.X..("\044 "..H.Z)Y.Anchored=true Y.Size=b Y.Position=H if Y.Position.Y<=-1 then Y.Color=Color3.fromRGB(255,220,114)Y.Material=Enum.Material.Sand elseif Y.Position.Y>-1 and Y.Position.Y<=1.25 then Y.Color=Color3.fromRGB(100,100,100)Y.Material=Enum.Material.Rock else Y.Color=Color3.fromRGB(0,85,0)Y.Material=Enum.Material.Grass end end end local function J(J,Y)if not Chunks:FindFirstChild(J..("\044 "..Y))then print(J..("\044 "..Y))local w=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")w.Parent=Chunks w.Name=J..("\044 "..Y)local O=game.Workspace.Terrain:FillBlock(CFrame.new(J,-10,Y),Vector3.new(Configuration.ChunkSize.Value,16,Configuration.ChunkSize.Value),Enum.Material.Water)for J=J+Configuration.ChunkSize.Value/2,(J-Configuration.ChunkSize.Value/2)+4,-Configuration.Grid.Value do for Y=Y+Configuration.ChunkSize.Value/2,(Y-Configuration.ChunkSize.Value/2)+4,-Configuration.Grid.Value do local O=b(J,Y)H(Configuration.GrassSize.Value,Vector3.new(J,O,Y),w)end task.wait()end end end if not Chunks:FindFirstChild("\048\044 \048")then J(0,0)end
-- / Functions / --
local function CreateNoise(GridX, GridZ, Seed)
	local GridY = math.noise(
		(GridX * Configuration.Frequency.Value) / 10,
		(GridZ * Configuration.Frequency.Value) / 10,
		Seed
	) * Random.new():NextNumber(19.5, 20)

	return GridY
end

local function CreateNewGrass(Size, Position, Parent)
	local ExistingBlock = Parent:FindFirstChild(Position.X .. ", " .. Position.Z)

	if ExistingBlock then
		print("existing")
	else
		local Block = Instance.new("Part")
		Block.Parent = Parent

		-- / Properties / --
		Block.Name = Position.X .. ", " .. Position.Z
		Block.Anchored = true
		Block.Size = Size
		Block.Position = Position

		-- / Visuals / --

		if Block.Position.Y <= -1 then
			Block.Color = Color3.fromRGB(255, 220, 114)
			Block.Material = Enum.Material.Sand
		elseif Block.Position.Y > -1 and Block.Position.Y <= 1.25 then
			Block.Color = Color3.fromRGB(100, 100, 100)
			Block.Material = Enum.Material.Rock
		else
			Block.Color = Color3.fromRGB(0, 85, 0)
			Block.Material = Enum.Material.Grass
		end
	end
	---game.Workspace.Terrain:FillBlock(CFrame.new(Position), Size, Enum.Material.Grass)
end

local function CreateNewChunk(ChunkPositionX, ChunkPositionZ)
	if not Chunks:FindFirstChild(ChunkPositionX .. ", " .. ChunkPositionZ) then
		print(ChunkPositionX .. ", " .. ChunkPositionZ)

		local NewChunk = Instance.new("StringValue")
		NewChunk.Parent = Chunks

		NewChunk.Name = ChunkPositionX .. ", " .. ChunkPositionZ

		local Water = game.Workspace.Terrain:FillBlock(
			CFrame.new(ChunkPositionX, -10, ChunkPositionZ),
			Vector3.new(Configuration.ChunkSize.Value, 16, Configuration.ChunkSize.Value),
			Enum.Material.Water
		)

		for iX = ChunkPositionX + (Configuration.ChunkSize.Value / 2), (ChunkPositionX - (Configuration.ChunkSize.Value / 2)) + 4, -Configuration.Grid.Value do
			for iZ = ChunkPositionZ + (Configuration.ChunkSize.Value / 2), (ChunkPositionZ - (Configuration.ChunkSize.Value / 2)) + 4, -Configuration.Grid.Value do
				local GridY = CreateNoise(iX, iZ)

				CreateNewGrass(Configuration.GrassSize.Value, Vector3.new(iX, GridY, iZ), NewChunk)
			end

			task.wait()
		end
	end
end

if not Chunks:FindFirstChild("0, 0") then
	CreateNewChunk(0, 0)
end
