So. I'm trying to make this script that goes through my model and check's if the Part's material is Concrete, and if it is, it changes its name...
A = game.Workspace.This:GetChildren() for i,v in pairs(A) do if v:Material("Concrete") then n.Name = "NotMe" end end
.Material
is not a method, it is a property. That means v.Material
is a value of some kind.
The Material property page on the Wiki will tell you that the value is a Material Enum.
Since you want to compare the material to Concrete to see if they are equal, you're probably going to use ==
.
You can either compare the name of the material, or directly compare enums. Comparing one kind to the other kind will always return false
since ==
first compares the types of the objects.
Since you will get an error if you mistype an enum name when using the Enum.
option, that's probably better:
if v.Material == Enum.Material.Concrete then
this is what i think it would be
for _,v in pairs do if v.Material = Material.Concrete then v.Name = "NotMe" end end
A = game.Workspace.This:GetChildren() for i,v in pairs(A) do if v.Material = Enum.Material.Concrete then v.Name = "NotMe" end end