How could I randomize things, like strings or materials?
1 | local part = Instance.new( "Part" ,workspace) |
2 | part.Material = Enum.Material.Grass --I want this to be a random value instead of grass, with it still being a material. |
Actually I checked with tutorials, but it can't random. Apparently you would need to make a table of all the materials and have it so it randomly chooses from the table.
1 | local part = Instance.new( "Part" ,workspace) |
2 | TableMaterial = { "Plastic" , "Wood" , "WoodPlanks" , "Slate" , "Concrete" , "Metal" , "CorrodedMetal" , "DiamondPlate" , "Foil" , "Grass" , "Ice" , "Brick" , "Sand" , "Fabric" , "Granite" , "Marble" , "Pebble" , "Cobblestone" , "SmoothPlastic" , "Neon" , "Glass" } |
3 |
4 | part.Material = (TableMaterial [ math.random(#TableMaterial) ] ) |
There you go :)
Sorry, but the best way is to just do something like this:
And, loop over it with ipairs, or just follow the example.
1 | local materials = { "Glass" , "Wood" , "etc." } |
2 | local rand = math.random(#materials) |
3 | part.Material = Enum.Material [ materials [ rand ] ] |
Hope That Helped.