Answered by
8 years ago Edited 8 years ago
As you should know, Materials are now accessed through Enum.Material
. And, since Enum is not an actual object, that means Enum (and it's children) are tables.
To sum that up, you don't need to define a materials table, you can just use the Enum;
1 | local materials = Enum.Material |
Now, here's the main problem (which is, luckily, easily fixed): The Enum tables are dictionaries, meaning we can't use a math.random
. Instead, we will convert the dictionary to an array;
1 | local oMaterials = Enum.Material |
4 | for _,v in pairs (oMaterials) do |
5 | table.insert(materials,v) |
As well as that, when searching for a child of a table, do this:
01 | local player = game.Players.LocalPlayer |
03 | local oMaterials = Enum.Materials |
06 | for _,v in pairs (oMaterials) do |
07 | table.insert(Materials,v) |
10 | script.Parent.MouseButton 1 Click:connect( function () |
11 | local PlayersHome = player.PlayersHome |
12 | if PlayersHome.Value ~ = nil then |
13 | local Walls = player.PlayersHome.Value.House.Walls |
15 | for i,v in pairs (Walls:GetChildren()) do |
16 | if v:IsA( 'UnionOperation' ) or v:IsA( 'Part' ) then |
17 | v.Material = Materials [ math.random( 1 ,#Materials) ] |
21 | script.Parent.Parent.Parent.Parent.FailFolder.Fail 2. Visible = true |
Hope I helped!
~TDP
P.S: Use tab, not space.