So I’m making a block generator, and I use perlin noise on the top layer for height variation. My strategy for filling in the holes is to check 1 block down for any blocks and if there isn’t, fill the hole and check again 1 block lower, however despite another block being successfully detected, the while loop seems to just keep going and spawning more blocks underneath. What do I do?
for i,v in pairs(topLayerParts) do
local noBlock = true
local block = v
while noBlock and block do
--print(noBlock)
newPart = block:Clone()
newPart.Position -= Vector3.new(0,newPart.Size.Y,0)
newPart.Parent = game.Workspace
wait()
for k,j in pairs(newPart:GetTouchingParts()) do
--print(j.Position, newPart.Position)
if j:IsA("BasePart") and j.Position == newPart.Position then
newPart:Destroy()
noBlock = false
block = nil
break
end
end
if not noBlock then break end
block = newPart
end
end