--[[
	Renomeie os blocos dentro de uma pasta para o nome relativo ao material, esse script tem que estar na raiz da pasta.
--]]

local tab = {"Ground", "CrackedLava", "Limestone", "Sandstone", "Basalt", "Asphalt",
			 "LeafyGrass", "Salt", "WoodPlanks", "Slate", "Concrete", "Sand", "Water",
			 "Pavement", "Brick", "Mud", "Grass", "Ice", "Rock", "Glacier", "Snow", "Air", "Neon"}
function isInTable(tableValue, toFind)
	local found = false
	for _,v in pairs(tableValue) do
		if v==toFind then
			found = true
            break;
		end
	end
	return found
end

local Folder = script.Parent
for i,v:BasePart in pairs(Folder:GetDescendants()) do
	if v:IsA("BasePart") then
		if isInTable(tab, v.Name) then
			print(Vector3.new(v.Size.X, v.Size.Y, v.Size.Z))
			print(Vector3.new(v.Size.X, v.Size.Y, v.Size.Z - (v.Size.Z % -20)))
			game.Workspace.Terrain:FillBlock(v.CFrame,Vector3.new(v.Size.X, v.Size.Y, v.Size.Z - (v.Size.Z % 20)),Enum.Material[v.Name])
		else
			return
		end
	end
	v:Destroy()
end

Folder.ChildAdded:Connect(function(child)
	wait()
	if child:IsA("BasePart") then
		if isInTable(tab, child.Name) then
			game.Workspace.Terrain:FillBlock(child.CFrame,child.Size,Enum.Material[child.Name])
		else
			return
		end
	end
	child:Destroy()
end)
