Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does generating Smooth Terrain via scripts result in a holey map?

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?

6 comments

0

It may be an bug on ROBLOX's side.

0

Hope not.

1

That seems quite odd. Try changing ipairs to pairs or changing line 11 to use the X or Z position, maybe? Not too sure.

0

That actually helps, not using the Y, since the height will never be larger than the width. Still having some issues, but thanks.

0

I would use RbxUtitily for that, because really workspace.Terrian does have a bug and ROBLOX just never fixed it yet. :/

0

RbxUtitily? explain please?

1 answer

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.

2 comments

1

No, that method takes a Vector3, according to the wiki. http://wiki.roblox.com/index.php?title=Smooth_terrain#FillBall

0

i dunno then :/

This discussion is preserved as it was. New answers, comments, and votes are closed.