How do i make this terrain chunk unloader work?

I want this script to unload the chunks another script has made when a player leaves a specific area. But it just does the opposite it just removes the chunks the player is in instead of removing the chunks around the player

I have tried quite many things but none works. This is the script (btw this is my first devforum post)

        	LoadedChar = false
        		LoadedChar = true
        		char.Humanoid.WalkSpeed = 100
        	until LoadedChar == true
        	local Char = plr.Character
        	local Root = Char:WaitForChild("HumanoidRootPart")
        	local Pos = Root.Position
        	local Render = game.ReplicatedStorage.RenderDistance.Value*4*8
        	local R =,0,Pos.Z-Render),,100,Pos.Z+Render))
        		local t = 0
        		local NotInside = {}
        		local PlayerDescendants = 0
        		local Players = game.Players:GetPlayers()
        		for i = 1,#Players do
        			for i = 1,#Players[i].Character:GetChildren() do
        				PlayerDescendants = PlayerDescendants + 1
        		print("Maximum = "..Render+#Players+PlayerDescendants)
        		local Inside = workspace:FindPartsInRegion3(R, Render+#Players+PlayerDescendants)
        		local Chunks = workspace.Ignore.ChunkParts:GetChildren()
        		for c = 1,#Chunks do
        			for i = 1,#Inside do
        				if Inside[i] == Chunks[c] then
        					t = t + 1
        					NotInside[t] = Chunks[c]
        		for i = 1,t do
        			local Chunk = NotInside[i]
        			workspace.Terrain:FillBlock(Chunk.CFrame, Chunk.Size, "Air")
        	until plr == nil

you appear to be collecting blocks that are matching hits with your ignore list.
I would have thought you would want to check each hit against all your ignore blocks until you have exhausted that list in which case the hit is not in the ignore list and needs to be destroyed.

and how do i do that? i am not so good at doing that, else i would not probably have asked. i just need an example on a for i loop.

In my opinion you should be looking through the Inside table first and then search through the Chunks table looking to see if this Inside item is within the ignore list.
If it is in the ignore list break out from the Chunks search and do the next Inside item Otherwise you have an Inside item that is not in the ignore so add it to the NotInside table.
Once you have looked at all the Inside items the NotInside table will contains all items that are to be processed for, in this case, filling with air.