I'm putting this script into the command bar of studio
for _, object in pairs(game.Workspace.Model:GetChildren()) do
if object.Material == "Marble" then
object.Name = "Hi"
endend
I'm trying to make every single block in Workspace thats material is Marble be named "Hi" - Why isn't this working? No errors.
So, if you were were to create a new part, set its material to "Plastic", and run this line of code in a script inside the part:
print(script.Parent.Material == 'Plastic')
This would print false
, as the material of the part is an Enumeration (enum) value not equal to the string "Plastic"
With that said, the following line would print "true"
print(script.Parent.Material == Enum.Material.Plastic)
So, a fixed version of your script would be something like:
for _, object in pairs(game.Workspace.Model:GetChildren()) do if object.Material == Enum.Material.Marble then object.Name = "Hi" end end