local w=chunkHandler:GetGrid()local f={}repeat wait()until game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.Parent==workspace while wait(4)do local Q=chunkHandler:GetChunkAtVector3(w,game.Players.LocalPlayer.Character.HumanoidRootPart.Position)if Q then local I=Q:GetNeighborChunks(w,3,true)local n={}for w,Q in pairs(I)do n[Q]=Q if f[Q]==nil then f[Q]=Q end Q:ShowResources()end n[Q]=Q Q:ShowResources()for w,Q in pairs(f)do if n[Q]==nil then print("\072\073\068\073\078\071 \067\072\085\078\075\083")Q:HideResources()f[Q]=nil end end end end
--local chunkHandler = require(game.ReplicatedStorage.Modules.Chunk_Handler)
local grid = chunkHandler:GetGrid()

local oldChunks = {}

repeat
	wait()
until game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.Parent == workspace

while wait(4) do
	local chunk = chunkHandler:GetChunkAtVector3(grid, game.Players.LocalPlayer.Character.HumanoidRootPart.Position)
	if chunk then
		local neighbors = chunk:GetNeighborChunks(grid, 3, true)

		local newChunks = {}

		for i, v in pairs(neighbors) do
			--[[local p = Instance.new("Part")
			p.Anchored = true
			p.CFrame = v.CFrame
			p.Size = Vector3.new(4, 4, 4)
			p.Parent = workspace
			game.Debris:AddItem(p, 2)]]

			newChunks[v] = v
			if oldChunks[v] == nil then
				oldChunks[v] = v
			end
			v:ShowResources()
		end

		newChunks[chunk] = chunk
		chunk:ShowResources()

		for _, oldChunk in pairs(oldChunks) do
			if newChunks[oldChunk] == nil then
				--This chunk is no longer in range
				print("HIDING CHUNKS")
				oldChunk:HideResources()
				oldChunks[oldChunk] = nil
			end
		end
	end
end
