How do I make a script that creates a block and spaces them out for every material I have

I’ve been trying to make a script that creates a block and spaces them out for every material I have, but it hasn’t been working

  1. What do you want to achieve?
    I need to see every materiel that I have so I can decide which one to use and which one to remove, also an a-z thing would help

  2. What is the issue?

I have tried it, but it only does 8 blocks (that are robloxs materials)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried some things and I did look on the developer hub

1 Like

Not exactly sure what you’re looking for, but you could try something like this:

local PART_COLOR: Color3 = Color3.fromRGB(63, 255, 127)
local PART_SIZE: Vector3 = Vector3.new(4,4,4)
local START_CFRAME: CFrame = CFrame.new(0,2,0)
local SORT_ALPHABETICAL: boolean = true

local materialList: {Enum.Material} = Enum.Material:GetEnumItems()
local materialModel: Model = Instance.new("Model")
materialModel.Name = "MaterialParts"

if SORT_ALPHABETICAL then
	table.sort(materialList, function(lhs: Enum.Material, rhs: Enum.Material)
		return lhs.Name < rhs.Name
	end)
end

for n: number, material: Enum.Material in materialList do
	local part: Part = Instance.new("Part", materialModel)
	part.Name = material.Name
	part.Anchored = true
	part.CFrame = START_CFRAME * CFrame.new((n - 1) * (1.5 * PART_SIZE.X), 0, 0)
	part.Color = PART_COLOR
	part.Material = material
	part.Size = PART_SIZE
end

materialModel.Parent = workspace

1 Like

This is how far I got (my script isn’t that good), but I’m trying to use my own materials (material variants)

You could try something like:

local MaterialService = game:GetService("MaterialService")
for _, matVariant in MaterialService:GetChildren() do
   if not matVariant:IsA("MaterialVariant") then continue end
   --matVariant is now guarunteed to be a MaterialVariant
   local part: Part = Instance.new("Part") --Need to set parent at some point
   part.Material = matVariant.BaseMaterial --If this isn't set, then the MaterialVariant will not work
   part.MaterialVariant = matVariant.Name
end

I’m new to scripting and I don’t understand how to make that work
Edit: I’m just dumb

I got it to work!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.