All necessary information is in the title, i simply want to have a function that returns all material variants of a given material. The issue is that I cant find any documentation on how to do this. I know there is a function that gets a specific material variant, but not by index or number. If i can get them by index that would still help tremendously
I am doing this for a plugin that generates houses to accelerate the building process of games, but I want users to be able to use their own material variants in it. I already have a color picker that I’ve created, which is far better than the native studio one, but I am still struggling with the materials.
MaterialVariants are stored in the Service of the same name, so iterate through them and categorize them based on their BaseMaterial
property
edit: some documentation MaterialVariant | Documentation - Roblox Creator Hub
I think you are misunderstanding the question. I know that each material variant has its base material stored, but I am not aware of any way to get material variants that isn’t by name. I don’t want the user to have to put in the name of each material variant, i just want it to show up there without any input.
Like this?
local Table = {}
for Index, WhichEnum in pairs(Enum.Material:GetEnumItems()) do
table.insert(Table, WhichEnum.Name)
end
EDIT: Pretty sure I’m incorrect
this gets all of the base materials, but it doesnt get material variants. I’m starting to wonder if there just isnt a way to get them
i didnt misunderstand anything, what im advising is how you do that. you iterate through all materialvariants stored inside MaterialService and categorize them based on their base material
example:
local allVariants = {}
for i, material in game:GetService("MaterialService"):GetDescendants()) do
if material:IsA("MaterialVariant") then
if not allVariants[material.BaseMaterial] then allVariants[material.BaseMaterial] = {} end
table.insert(allVariants[material.BaseMaterial], material)
end
end
omg i didnt know that material variants are stored in material service. I’ll try that and get back to you
(also sorry for wasting extra time)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.