Perlin noise weird glitch

So I’ve been working on an Infinite Mining game, while trying to make caves, I’ve ran into a weird glitch. I couldn’t find anyone else with this problem, so I decided to make this, Here is my OreModule:

local Ore = {}
Ore.Info = {
	["Stone"] = {
		Cash = 0,
		Depths = { Min = 0, Max = 1000 },
		Rarity = 0,
		RarityName = "Layer",
		RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
		NameColor = Color3.new(0.580392, 0.580392, 0.580392)
	},
	["Basalt"] = {
		Cash = 0,
		Depths = { Min = 1001, Max = 2000 },
		Rarity = 0,
		RarityName = "Layer",
		RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
		NameColor = Color3.new(0.690196, 0.690196, 0.690196)
	},
	["Diorite"] = {
		Cash = 0,
		Depths = { Min = 2001, Max = 3000 },
		Rarity = 0,
		RarityName = "Layer",
		RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
		NameColor = Color3.new(0.898039, 0.898039, 0.898039)
	},
	["Granite"] = {
		Cash = 0,
		Depths = { Min = 3001, Max = 4000 },
		Rarity = 0,
		RarityName = "Layer",
		RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
		NameColor = Color3.new(0.588235, 0.588235, 0.588235)
	},
	["Obsidian"] = {
		Cash = 0,
		Depths = { Min = 4001, Max = 5000 },
		Rarity = 0,
		RarityName = "Layer",
		RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
		NameColor = Color3.new(0.105882, 0.105882, 0.105882)
	},
	["Mantle"] = {
		Cash = 0,
		Depths = { Min = 5001, Max = 6000 },
		Rarity = 0,
		RarityName = "Layer",
		RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
		NameColor = Color3.new(0.85098, 0.227451, 0.0392157)
	},
	["Core"] = {
		Cash = 0,
		Depths = { Min = 6001, Max = 7000 },
		Rarity = 0,
		RarityName = "Cave",
		RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
		NameColor = Color3.new(0.866667, 0.54902, 0.0352941)
	},
	--["Reflectistone"] = {
	--	Cash = 0,
	--	Depths = { Min = 0, Max = 7000 }, -- Wide range since it's cave-specific
	--	Rarity = 0, -- 0 rarity since it's a cave layer ore
	--	RarityName = "Cave",
	--	RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
	--	NameColor = Color3.new(0.9, 0.9, 0.95) -- Light reflective color
	--},

	--["Gemstone"] = {
	--	Cash = 0,
	--	Depths = { Min = 0, Max = 7000 },
	--	Rarity = 0,
	--	RarityName = "Layer",
	--	RarityColor = Color3.new(0.454902, 0.454902, 0.454902),
	--	NameColor = Color3.new(0.6, 0.2, 0.8)
	--},
	["Copper"] = {
		Cash = 0.01,
		Depths = { Min = 1, Max = 7000 },
		Rarity = 90,
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(0.552941, 0.352941, 0.152941)
	},
	["Nickel"] = {
		Cash = 0.01,
		Depths = { Min = 6001, Max = 7000 },
		Rarity = 120,
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(0.552941, 0.352941, 0.152941)
	},
	["Glitch"] = {
		Cash = 0,
		Depths = { Min = 666, Max = 670 },
		Rarity = 999999999999999,
		RarityName = "Primordial",
		RarityColor = Color3.new(0.223529, 0.121569, 0.345098),
		NameColor = Color3.new(0.760784, 0.0784314, 0.74902)
	},
	["Gold"] = {
		Cash = 0.02,
		Depths = { Min = 15, Max = 7000 },
		Rarity = 190, -- Rare
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(1, 0.968627, 0.541176)
	},
	["Iron"] = {
		Cash = 0.01,
		Depths = { Min = 1, Max = 7000 },
		Rarity = 190, -- Rare
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(0.666667, 0.709804, 0.709804)
	},
	["Coal"] = {
		Cash = 0.01,
		Depths = { Min = 0, Max = 10000 },
		Rarity = 145, -- Rare
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(0.0901961, 0.0941176, 0.0941176)
	},
	["Silver"] = {
		Cash = 0.02,
		Depths = { Min = 1, Max = 7000 },
		Rarity = 400, -- Rare
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(0.827451, 0.827451, 0.827451)
	},
	["Quartz"] = {
		Cash = 0.02,
		Depths = { Min = 1, Max = 7000 },
		Rarity = 200, -- Rare
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(0.968627, 0.968627, 0.968627)
	},
	["Emerald"] = {
		Cash = 0.03,
		Depths = { Min = 30, Max = 1000 },
		Rarity = 600, -- Rare
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(0.160784, 0.631373, 0.192157)
	},
	["Ruby"] = {
		Cash = 0.03,
		Depths = { Min = 30, Max = 5000 },
		Rarity = 600, -- Rare
		RarityName = "Common",
		RarityColor = Color3.new(0.635294, 0.635294, 0.635294),
		NameColor = Color3.new(255, 0, 0)
	},
	["Cobalt"] = {
		Cash = 0.21,
		Depths = { Min = 70, Max = 3000 },
		Rarity = 1200, -- Very Rare
		RarityName = "Uncommon",
		RarityColor = Color3.new(0.898039, 0.203922, 0.215686),
		NameColor = Color3.new(0.0509804, 0.443137, 0.745098)
	},
	["Periclase"] = {
		Cash = 0.57,
		Depths = { Min = 70, Max = 3000 },
		Rarity = 2660, -- Very Rare
		RarityName = "Uncommon",
		RarityColor = Color3.new(0.898039, 0.203922, 0.215686),
		NameColor = Color3.new(0.439216, 0.827451, 0.698039)
	},
	["Amethyst"] = {
		Cash = 0.78,
		Depths = { Min = 70, Max = 3000 },
		Rarity = 3100, -- Very Rare
		RarityName = "Uncommon",
		RarityColor = Color3.new(0.898039, 0.203922, 0.215686),
		NameColor = Color3.new(0.478431, 0.109804, 0.745098)
	},
	["Relicstone"] = {
		Cash = 0.84,
		Depths = { Min = 70, Max = 1000 },
		Rarity = 3200, -- Very Rare
		RarityName = "Uncommon",
		RarityColor = Color3.new(0.898039, 0.203922, 0.215686),
		NameColor = Color3.new(0.870588, 0.803922, 0.0588235)
	},
	["Amazonite"] = {
		Cash = 3.72,
		Depths = { Min = 70, Max = 3000 },
		Rarity = 9800, -- Very Rare
		RarityName = "Rare",
		RarityColor = Color3.new(0.329412, 0.133333, 0.870588),
		NameColor = Color3.new(0.0392157, 0.870588, 0.482353)
	},
	["Ignitium"] = {
		Cash = 2.19,
		Depths = { Min = 5001, Max = 6000 },
		Rarity = 6800, -- Very Rare
		RarityName = "Rare",
		RarityColor = Color3.new(0.329412, 0.133333, 0.870588),
		NameColor = Color3.new(1, 0.596078, 0.0313725)
	},
	["Viridite"] = {
		Cash = 1.97,
		Depths = { Min = 80, Max = 1000 },
		Rarity = 5100, -- Extremely Rare
		RarityName = "Rare",
		RarityColor = Color3.new(0.329412, 0.133333, 0.870588),
		NameColor = Color3.new(0.105882, 0.772549, 0.105882)
	},
	["Azurite"] = {
		Cash = 3.11,
		Depths = { Min = 20, Max = 1000 },
		Rarity = 7600, -- Extremely Rare
		RarityName = "Rare",
		RarityColor = Color3.new(0.329412, 0.133333, 0.870588),
		NameColor = Color3.new(0.0352941, 0.145098, 0.772549)
	},
	["Hematite"] = {
		Cash = 2.26,
		Depths = { Min = 0, Max = 5000 },
		Rarity = 6950, -- Extremely Rare
		RarityName = "Rare",
		RarityColor = Color3.new(0.329412, 0.133333, 0.870588),
		NameColor = Color3.new(0.0470588, 0.0470588, 0.0470588)
	},
	["Solarbane"] = {
		Cash = 14.56,
		Depths = { Min = 6001, Max = 7000 },
		Rarity = 27500, -- Extremely Rare
		RarityName = "Master",
		RarityColor = Color3.new(0.776471, 0.0588235, 0.870588),
		NameColor = Color3.new(0.956863, 0.796078, 0)
	},
	["Elasticite"] = {
		Cash = 21.2,
		Depths = { Min = 2001, Max = 3000 },
		Rarity = 48900, -- Extremely Rare
		RarityName = "Master",
		RarityColor = Color3.new(0.776471, 0.0588235, 0.870588),
		NameColor = Color3.new(0.85098, 0.831373, 0.760784)
	},
	["Powellite"] = {
		Cash = 34.17,
		Depths = { Min = 0, Max = 2000 },
		Rarity = 70199, -- Extremely Rare
		RarityName = "Master",
		RarityColor = Color3.new(0.776471, 0.0588235, 0.870588),
		NameColor = Color3.new(0.87451, 0.882353, 0.466667)
	},
	["Pyre"] = {
		Cash = 81,
		Depths = { Min = 5001, Max = 6000 },
		Rarity = 291000, -- Extremely Rare
		RarityName = "Elite",
		RarityColor = Color3.new(0.870588, 0.054902, 0.368627),
		NameColor = Color3.new(1, 0.835294, 0.0117647)
	},
	["Barite"] = {
		Cash = 157.7,
		Depths = { Min = 1001, Max = 3000 },
		Rarity = 492700, -- Extremely Rare
		RarityName = "Elite",
		RarityColor = Color3.new(0.870588, 0.054902, 0.368627),
		NameColor = Color3.new(1, 0.956863, 0.368627)
	},
	["Vacantine"] = {
		Cash = 85.24,
		Depths = { Min = 5001, Max = 6000 },
		Rarity = 378900, -- Extremely Rare
		RarityName = "Elite",
		RarityColor = Color3.new(0.870588, 0.054902, 0.368627),
		NameColor = Color3.new(0.137255, 0.0156863, 0.188235)
	},
	["Ammolite"] = {
		Cash = 130.1,
		Depths = { Min = 0, Max = 1000 },
		Rarity = 478500, -- Extremely Rare
		RarityName = "Elite",
		RarityColor = Color3.new(0.870588, 0.054902, 0.368627),
		NameColor = Color3.new(0.0666667, 0.568627, 0.882353)
	},
	["Numerical Crystal"] = {
		Cash = 36.01,
		Depths = { Min = 2001, Max = 3000 },
		Rarity = 101010, -- Extremely Rare
		RarityName = "Elite",
		RarityColor = Color3.new(0.870588, 0.054902, 0.368627),
		NameColor = Color3.new(0.278431, 0, 0.882353)
	},
	["Corundum"] = {
		Cash = 94,
		Depths = { Min = 0, Max = 2000 },
		Rarity = 326999, -- Extremely Rare
		RarityName = "Elite",
		RarityColor = Color3.new(0.870588, 0.054902, 0.368627),
		NameColor = Color3.new(0.780392, 0.278431, 0.882353)
	},
	["Chromatium"] = {
		Cash = 233.33,
		Depths = { Min = 1001, Max = 2000 },
		Rarity = 779977, -- Extremely Rare
		RarityName = "Legendary",
		RarityColor = Color3.new(0.866667, 0.380392, 0.866667),
		NameColor = Color3.new(0.721569, 0.74902, 1)
	},
	["Vortexium"] = {
		Cash = 2101.2,
		Depths = { Min = 2001, Max = 3000 },
		Rarity = 5600000, -- Extremely Rare
		RarityName = "Exotic",
		RarityColor = Color3.new(0.968627, 0.745098, 0.0705882),
		NameColor = Color3.new(0.47451, 0.47451, 0.47451)
	},
	["Duplicatium"] = {
		Cash = 1006.78,
		Depths = { Min = 3001, Max = 4000 },
		Rarity = 2300000, -- Extremely Rare
		RarityName = "Exotic",
		RarityColor = Color3.new(0.968627, 0.745098, 0.0705882),
		NameColor = Color3.new(0.360784, 0.913725, 1)
	},
	["Volatile Flare"] = {
		Cash = 18425.2,
		Depths = { Min = 6001, Max = 7000 },
		Rarity = 47500000, -- Extremely Rare
		RarityName = "Ascendent",
		RarityColor = Color3.new(0.12549, 0.164706, 0.870588),
		NameColor = Color3.new(0, 0, 0)
	},
	["Seaborgium"] = {
		Cash = 11301.1,
		Depths = { Min = 5001, Max = 6000 },
		Rarity = 21330000, -- Extremely Rare
		RarityName = "Ascendent",
		RarityColor = Color3.new(0.12549, 0.164706, 0.870588),
		NameColor = Color3.new(0.898039, 0.411765, 0.0117647)
	},
	["Galvanitium"] = {
		Cash = 8741.98,
		Depths = { Min = 150, Max = 1000 },
		Rarity = 23000000, -- Extremely Rare
		RarityName = "Ascendent",
		RarityColor = Color3.new(0.12549, 0.164706, 0.870588),
		NameColor = Color3.new(0.921569, 0.996078, 0.243137)
	},
	["Windforce"] = {
		Cash = 124.4,
		Depths = { Min = 3001, Max = 4000 },
		Rarity = 450000, -- Extremely Rare
		RarityName = "Elite",
		RarityColor = Color3.new(0.870588, 0.054902, 0.368627),
		NameColor = Color3.new(0.321569, 0.996078, 0.364706)
	},
	["Bubbal"] = {
		Cash = 212166.7,
		Depths = { Min = 0, Max = 3000 },
		Rarity = 49999999, -- Extremely Rare
		RarityName = "Sublime",
		RarityColor = Color3.new(0.368627, 0.00784314, 0.270588),
		NameColor = Color3.new(0.996078, 0.996078, 0.996078)
	},
	--["Hyperflare"] = {
	--	Cash = 1462.44,
	--	Depths = { Min = 1001, Max = 2000 },
	--	Rarity = 167000000, -- Extremely Rare
	--	RarityName = "Omnipotent",
	--	RarityColor = Color3.new(0.145098, 0.101961, 0.368627),
	--	NameColor = Color3.new(0.207843, 0.823529, 0.996078)
	--},
	["3RR0R"] = {
		Cash = 34500.2,
		Depths = { Min = 4001, Max = 5000 },
		Rarity = 66666666, -- Extremely Rare
		RarityName = "Omnipotent",
		RarityColor = Color3.new(0.145098, 0.101961, 0.368627),
		NameColor = Color3.new(0.815686, 0, 0.0117647)
	},
	["Dimensional Pulsar"] = {
		Cash = 41591.78,
		Depths = { Min = 4001, Max = 5000 },
		Rarity = 77800000, -- Extremely Rare
		RarityName = "Omnipotent",
		RarityColor = Color3.new(0.145098, 0.101961, 0.368627),
		NameColor = Color3.new(0.392157, 0.0941176, 0.815686)
	},
	--["CosmicFragment"] = {
	--	Cash = 1000000,
	--	Depths = { Min = 0, Max = 1000 },
	--	Rarity = 99.999999999999999999978, -- Ultra Rare (0.000000000000000000022% chance)
	--},
};


--0 = layer
--1-500 = common
--500-5000 = uncommon
--5000-10000 = rare
--10000-75000 = master
--75000-500000 = elite
--500000-1000000 = legendary
--1000000-10000000 = exotic
--10000000-50000000 = ascendent
--50000000-100000000 = omnipotent
--100000000-1000000000 = sublime
--1000000000+ = primordial

Ore.DepthLayers = {
	{MaxDepth = 1000, DefaultOre = "Stone"},
	{MaxDepth = 2000, DefaultOre = "Basalt"},
	{MaxDepth = 3000, DefaultOre = "Diorite"},
	{MaxDepth = 4000, DefaultOre = "Granite"},
	{MaxDepth = 5000, DefaultOre = "Obsidian"},
	{MaxDepth = 6000, DefaultOre = "Mantle"},
	{MaxDepth = 7000, DefaultOre = "Core"},
}

local Origin = CFrame.new(0, 10, 0)
local SavedPositions = {}
local CaveResolution = 40
local Thrash = 0.35
local MCD = 0.1
local CanMine = true

local CaveTypes = require(game.ReplicatedStorage.Modules.CaveTypes)

math.randomseed(tick())

local sortedpairs=function(t,order)
    local keys = {}
    for k in pairs(t) do keys[#keys+1] = k end
    if order then
        table.sort(keys, function(a,b) return order(t, a, b) end)
    else
        table.sort(keys)
    end
    local i = 0
    return function()
        i = i + 1
        if keys[i] then
            return keys[i], t[keys[i]]
        end
    end
end

local function GetDefaultOre(depth)
	for _, layer in ipairs(Ore.DepthLayers) do
		if depth <= layer.MaxDepth then
			return layer.DefaultOre
		end
	end
	return Ore.DepthLayers[#Ore.DepthLayers].DefaultOre
end

function Ore.GenerateOre(x, y, z, mining, luck)
	local gotPos = CFrame.new(x*6,y*6,z*6)
	if mining and (mining * gotPos).Y > Origin.Y then return end
	if mining and SavedPositions[tostring((mining * gotPos).p)] then return end
	local oCF = (mining and (mining * gotPos)) or (Origin * gotPos)
	local thingy = (mining and (mining * gotPos)) or (Origin * gotPos)
	local ore = PickOre(thingy)
	local Mineable = Instance.new("BoolValue")
	Mineable.Name = "CanMine"
	Mineable.Value = true
	ore.CFrame = oCF
	if mining and (mining * gotPos).Y >= Origin.Y then
		Mineable.Value = false
	end
	SavedPositions[tostring(ore.Position)] = true
	Mineable.Parent = ore
	ore.Parent = workspace.Ores

	local m = math.noise(
		(ore.CFrame.X)/CaveResolution,
		ore.CFrame.Y/CaveResolution,
		ore.CFrame.Z/CaveResolution
	)

	if m > Thrash and ore.CFrame.Y < Origin.Y then
		task.spawn(function()
			Ore.MineOre(nil, ore)
		end)
		return ore
	end
end


function PickOre(layer, player, luckBoost)
local Event = require(game.ReplicatedStorage.Modules.EventModule)
local availableOres = {}
local Y = math.abs((layer.Y-Origin.Y)/6)
local defaultOre = GetDefaultOre(Y)

for oreName, oreInfo in pairs(Ore.Info) do
	if oreInfo.RarityName ~= "Cave" then
		if Y >= oreInfo.Depths.Min and Y <= oreInfo.Depths.Max then
			table.insert(availableOres, oreName)
		end
	end
end

if #availableOres == 0 then
	table.insert(availableOres, defaultOre)
end

for _ = 1, #availableOres do
	local randomOre = availableOres[math.random(#availableOres)]
	local rarity = Ore.Info[randomOre].Rarity

	if rarity and rarity > 0 then
		local adjustedRarity = luckBoost and math.max(1, math.floor(rarity / (1 + luckBoost))) or rarity
		if math.random(1, adjustedRarity) == 1 then
			local MakeOre = game.ReplicatedStorage.OresFolder:FindFirstChild(randomOre):Clone()
			local oreInfo = Ore.Info[randomOre]
			if oreInfo.RarityName == "Exotic" or 
				oreInfo.RarityName == "Ascendent" or 
				oreInfo.RarityName == "Omnipotent" or 
				oreInfo.RarityName == "Sublime" or 
				oreInfo.RarityName == "Primordial" then
				Event.SpawnMessage(oreInfo)
			end
			return MakeOre
		end
	end
end

local MakeOre = game.ReplicatedStorage.OresFolder:FindFirstChild(defaultOre):Clone()
return MakeOre
end

--local function dropGear(position)
--	local GearModule = require(game.ReplicatedStorage.Modules.GearModule)
--	local gearNames = {}
--	for gearName, _ in pairs(GearModule.Info) do
--		table.insert(gearNames, gearName)
--	end

--	local randomGearName = gearNames[math.random(#gearNames)]
--	local gearModel = game.ReplicatedStorage.GearsFolder:FindFirstChild(randomGearName)

--	if gearModel then
--		local droppedGear = gearModel:Clone()
--		droppedGear.Name = "DroppedGear_" .. randomGearName
--		droppedGear:SetPrimaryPartCFrame(CFrame.new(position + Vector3.new(0, 2, 0)))

--		for _, part in pairs(droppedGear:GetDescendants()) do
--			if part:IsA("BasePart") then
--				part.Anchored = false
--				part.CanCollide = true
--			end
--		end

--		droppedGear.Parent = workspace

--		local explosionTime = math.random(3, 5)
--		delay(explosionTime, function()
--			local gearInfo = GearModule.Info[randomGearName]
--			if gearInfo and gearInfo.Effect then
--				local nearestPlayer = nil
--				local minDistance = math.huge
--				for _, player in pairs(game.Players:GetPlayers()) do
--					local character = player.Character
--					if character and character.PrimaryPart then
--						local distance = (character.PrimaryPart.Position - droppedGear.PrimaryPart.Position).Magnitude
--						if distance < minDistance then
--							nearestPlayer = player
--							minDistance = distance
--						end
--					end
--				end

--				if nearestPlayer then
--					gearInfo.Effect(nearestPlayer)
--				end
--			end
--			droppedGear:Destroy()
--		end)
--	else
--		warn("Gear model not found:", randomGearName)
--	end
--end

function Ore.MineOre(plr, target, bypassPickaxeCheck, luck)
	local bm = require(game.ReplicatedStorage.Modules.BountyModule)

	if not bypassPickaxeCheck then
		if plr then
			local character = plr.Character
			if character then
				local tool = character:FindFirstChildOfClass("Tool")
				if not tool or not tool:FindFirstChild("isPick") then
					print("Player must have a pickaxe equipped to mine")
					return
				end
			else
				print("Player character not found")
				return
			end
		end
	end
	
	if plr and _G.PlayerData[plr.Name] then
		if not _G.PlayerData[plr.Name].Ores[target.Name] then
			_G.PlayerData[plr.Name].Ores[target.Name] = 0
		end

		_G.PlayerData[plr.Name].Ores[target.Name] = _G.PlayerData[plr.Name].Ores[target.Name] + 1
		bm.UpdateProgress(plr, target.Name)
		_G.PlayerData[plr.Name].BlocksMined = (_G.PlayerData[plr.Name].BlocksMined or 0) + 1
	end

	task.spawn(function()
		for x = -1,1 do
			Ore.GenerateOre(x,0,0,target.CFrame, luck)
		end
		for y = -1,1 do
			Ore.GenerateOre(0,y,0,target.CFrame, luck)
		end
		for z = -1,1 do
			Ore.GenerateOre(0,0,z,target.CFrame, luck)
		end
	end)

	target:Destroy()
end

function Ore.StartMine()
	local density = 1.5
	workspace.Ores:ClearAllChildren()
	SavedPositions = {}
	for x = 1, 16 do
		for z = 1, 16 do
			if math.random() < density then
				Ore.GenerateOre(x, 0, z)
			end
		end
	end
end

--function Ore.ResetMine(plrs)
--	workspace.Ores:ClearAll

Children()
– SavedPositions = {}
– plrs.Position = workspace.SpawnLocation.Position
–end

return Ore

Sorry if its unreadable I’m not very experienced on devforum yet. The problem is that when I go past 30~35 cave resolution, my caves start having a lot of empty spaces like this

Oh and if it wasnt clear, the cave generation code is in the GenerateOre function and starts at local m = math.noise(etc…)

Try turning on StreamingEnabled or other Streaming properties. I believe they are in workspace.

Just a guess but it might be your math.noise xyz input sometimes ends up being all integers at those resolutions. If math.noise has ALL integers it ALWAYS returns zero — math.noise(32, 673, 2765) == 0

You could try add arbitrary decimal values to prevent this, even if this doesn’t solve your problem this is a good thing to do with noise anyways to avoid the integer case.

local m = math.noise(
	(ore.CFrame.X + 0.5236) / CaveResolution,
	(ore.CFrame.Y + 0.2474) / CaveResolution,
	(ore.CFrame.Z - 0.8937) / CaveResolution
)


I used both current solutions (yours and the streaming enabled one
image
it seems to look a bit more closed, but it’s still going on