Basically, I have a grid of many 15x15 Parts. I use code to edit these Parts' color and Y size, somewhat randomly. I then use the color and size of the Parts to generate Smooth Terrain with the correct size and material.
The regular Parts are changing color and size just fine. However, when I go to generate the Smooth Terrain, for some reason the map is full of holes. It's doesn't make a lot of sense.
This is my grid of regular Parts.
This is what happens when I edit their size and color, prepping for the terrain generation.
This is what happens when I generate the terrain. See the holes? Currently I just manually made the Parts invisible so you can see the terrain clearly, although they will eventually be getting deleted after the terrain is formed.
This is the function I use for generating terrain based on the properties of the Parts:
function smoothTerrain() --'loaded' is just a Model filled with all the correctly colored and sized Parts. for i, part in ipairs(loaded:GetChildren()) do if part.BrickColor == BrickColor.Blue() then workspace.Terrain:FillBlock(part.CFrame, part.Size, "Water") elseif part.BrickColor == BrickColor.Green() then local shape = math.random(1, 2) if shape == 1 then workspace.Terrain:FillBlock(part.CFrame, part.Size, "Grass") else workspace.Terrain:FillBall(part.Position, part.Size.Y/2, "Grass") end else workspace.Terrain:FillBlock(part.CFrame, part.Size, "Sand") end end end
How can I fix this holey map?
function smoothTerrain() --'loaded' is just a Model filled with all the correctly colored and sized Parts. for i, part in ipairs(loaded:GetChildren()) do if part.BrickColor == BrickColor.Blue() then workspace.Terrain:FillBlock(part.CFrame, part.Size, "Water") elseif part.BrickColor == BrickColor.Green() then local shape = math.random(1, 2) if shape == 1 then workspace.Terrain:FillBlock(part.CFrame, part.Size, "Grass") else workspace.Terrain:FillBall(part.Position, part.Size.Y/2, "Grass") -- nope. end else workspace.Terrain:FillBlock(part.CFrame, part.Size, "Sand") end end end
You do it right in FillBlock but in FillBall you do it wrong. (I've noticed no balls are shown)
Replace the
part.Position
with
part.CFrame
wich leads to
function smoothTerrain() --'loaded' is just a Model filled with all the correctly colored and sized Parts. for i, part in ipairs(loaded:GetChildren()) do if part.BrickColor == BrickColor.Blue() then workspace.Terrain:FillBlock(part.CFrame, part.Size, "Water") elseif part.BrickColor == BrickColor.Green() then local shape = math.random(1, 2) if shape == 1 then workspace.Terrain:FillBlock(part.CFrame, part.Size, "Grass") else workspace.Terrain:FillBall(part.CFrame, part.Size.Y/2, "Grass") end else workspace.Terrain:FillBlock(part.CFrame, part.Size, "Sand") end end end
Sorry, I can't fully explain why this happens since I'm not a CFrame expert, but I do know CFrame is not Position!
Hope this helps! Thanks, marcoantoniosantos3.