Hello everyone.
My game involves selecting a random material for lots of separate objects. First, I attempted this by selecting a random material from an array, and then setting the object's material to that.
local mat = {"Plastic","SmoothPlastic","Neon","Wood","WoodPlanks","Marble","Slate","Concrete","Granite","Brick","Pebble","Cobblestone","CorrodedMetal","DiamondPlate","Foil","Metal","Grass","Sand","Fabric","Ice"}
local children = script.Parent.LeftBackLeg:GetChildren()
for i, child in ipairs(children) do
local material = mat[math.random(0,19)]
child.Material = Enum.Material.material
end
This gave me the error: "material is not a valid EnumItem" which I suppose makes sense because I said to set it to that? But I already selected a random material from the array which confuses me.
Is there any way to do this besides select a random number using math.random and saying if it's that number it selects a different material (extremely tedious).
Thanks! :D

3 comments
I will test this out when I get to my computer. If it works I will accept it! Thanks for the good ideas man
no problem
Enum.Material[material] worked. Tysm!