Creating blocks around mined area

Seems to work!! :smiley: Thank you!! :smiley: I’ll do some testing and make sure everything’s good, but it looks good atm :smiley:

Starting to get problems where the bedrock can sometime generate twice over the same spot
First image shows 4 (correct amount of bedrock)


But if I mine a block under the bedrock, then it creates another bedrock

So the block here I’m pointing at has 2 bedrocks on top of each other

local function CreateOre(ore, position)
	ore.Parent = Mine
	ore.CFrame = position

	local BlockDataName = ('%d,%d,%d'):format(ore.Position.X, ore.Position.Y, ore.Position.Z)
	
	if ShouldPlaceBedrockAt(position) then
		print(1)
		ore:Destroy()
		CreateBedrock(position)
	end
	
	if math.floor(position.Y + 0.5) > LayerLimits.Surface or BlockData:FindFirstChild(BlockDataName) then
		ore:Destroy()
	end
	
	if position.Y == LayerLimits.Bedrock then
		CreateBedrock(position)
		ore:Destroy()
	end
	
	if ore then
		local BlockPosData = Instance.new('Folder')
		BlockPosData.Name = BlockDataName
		BlockPosData.Parent = BlockData
	end
end

That would be because you don’t check the BlockData before calling CreateBedrock. Try changing that first if statement to this;

if ShouldPlaceBedrockAt(position) then
	print(1)
	ore:Destroy()
	if not BlockData:FindFirstChild(BlockDataName) then
		CreateBedrock(position)
	end
end
1 Like