Converting Parts into Terrain?

Dont have the code rn since i deleted but i remember it.

local function convert(chunk)
       local instances = chunk.instances

       for i,v in pairs(instances) do
              if v.Name == "Wedge" then
                     workspace.Terrain:FillBlock(v.CFrame,v.Size,Enum.Material.Grass)
                    v:Destroy()
                    table.remove(instances,i)
              end
       end
end

Idk if the table.remove thing worked but whatever

2 Likes

You don’t need table.remove for this

2 Likes

original code didn’t have it, it still didn’t work sadly :frowning:

Are you sure instances is an array of part already?

1 Like

Yeah, instances are an array of parts, also i checked if its named “Wedges” since trees are also stored there.

The string you specified is “Wedge” though

1 Like

I didnt rename the Wedges, idk why i put it in quotation

Its still named “Wedge”

Can you try print(instances) before the for loop and screenshot the output table expanded?

1 Like

Studio crashed but whatever

Also ill show u what it looks like
received_484245646867171

It literally just makes no parts at all when i remove “table.remove”

I printed v.CFrame and v.Size

--CFrame \/--
772.5, -16.9695091, 765, -0.17906189, 0.684085429, 0.707081199, 0.969490528, 0.244981378, 0.00850054342, -0.167406663, 0.687030613, -0.707081199
--Size \/--
0.0010000000474974513, 10.939990997314453, 10.629768371582031

It is a possibility that the thickness of these are a bit too small for an actual terrain to be made

Try set the X axis size to 1 to see if it works

1 Like

OOH I’VE DONE THIS BEFORE lemme see if I can find the code…

1 Like

I mean yeah prob, should i add to size? Like 10 every axis?

Alr

Try just 1 on the slim axis, the X

1 Like

It worked but like:
image
You see the dots or is it just me?

snippet from some code of mine, where w1 and w2 are wedges, hopefully you can adapt it

	if TERRAIN then
			local success, err = pcall(function()
				if value.water then
					Terrain:FillWedge(w1.CFrame,w1.Size+Vector3.new(5,4,4),Enum.Material.Water)
					Terrain:FillWedge(w2.CFrame,w2.Size+Vector3.new(5,4,4),Enum.Material.Water)
				elseif value.coast then
					Terrain:FillWedge(w1.CFrame,w1.Size+Vector3.new(5,4,4),Enum.Material.Sand)
					Terrain:FillWedge(w2.CFrame,w2.Size+Vector3.new(5,4,4),Enum.Material.Sand)
				else
					Terrain:FillWedge(w1.CFrame,w1.Size+Vector3.new(5,4,4),Enum.Material.Grass)
					Terrain:FillWedge(w2.CFrame,w2.Size+Vector3.new(5,4,4),Enum.Material.Grass)
				end
			end)
		end
1 Like

the reason i added extra values to the size vectors was to reduce dots/holes like you’ve seen already, assuming those holes arise by the same reason

1 Like

Works on surface! Although i got another problem:

Yeah, underwater it doesn’t look too good sadly

1 Like

Oops, perhaps the triangles are simply too small or something? I’m really not sure what’d cause that :sweat_smile:

1 Like

Maybe ill try changing some values… Im gonna test if it works normally without convert underwater too, maybe its just the code

Works good without the convert function

Yep changed values worked perfectly!

v.Size+Vector3.new(20,20,20)
1 Like

Hi do you know if there’s a script I can put in the command bar to turn parts that are named a certain thing to terrain? Like “Grass Block” and turn it into roblox terrain grass?