i wanted a script that could make every block corroded, for my core. here is what i TRIED:
game.Workspace.GetChildren.Material("Corroded Metal")
but GetChildren
and Material
were both not accepted. They are not correct commands. if you have the correct commands, or a whole new script, that would be great! thanks!
This function is basically an expanded form of fireboltofdeath's answer:
function ChangeMaterial(Obj) for _,v in pairs(Obj:GetChildren()) do if v:IsA("BasePart") then v.Material = Enum.Material.CorrodedMetal end ChangeMaterial(v) end end ChangeMaterial(game.Workspace)
This function will iterate through all the children of the workspace, the through the children's children, and so forth. It will get every single brick in the workspace and change its Material
to CorrodedMetal
. Hope this helped!
for i,v in pairs(workspace:GetChildren()) do if v:IsA("Part") then v.Material = "Corroded Metal" elseif v:IsA("Model") then for k,g in pairs(v:GetChildren()) do if g:IsA("Part") then g.Material = "Corroded Metal" end end end end
This uses GetChildren to detect if it is a part or a model. If it is a model it'll look inside for more parts.