Is there an easy way to shorten this line of code?
if (part.Material == Enum.Material.Concrete or part.Material == Enum.Material.Slate or part.Material == Enum.Material.Cobblestone or part.Material == Enum.Material.Granite or part.Material == Enum.Material.Marble) then
Use tables. Tables have an array part and a dictionary part. The dictionary part is an unordered mapping of key-value pairs.
local materials = { Concrete = true, Slate = true, Cobblestone = true, Granite = true, Marble = true } if (materials[part.Material.Name]) then -- something end
If the name of the material is a key in the table, materials[part.Material.Name]
will evalĂșate to true
. Otherwise nil
.