Hey there, I was wondering if there was a way I can get all the neon parts in the workspace and turn them red. this is for my alarm system, the code I tried is below.
for _,v in pairs(workspace:GetChildren()) do if v:IsA("BasePart") and v.Material:Is("Neon") then end end
for _, Part in ipairs(workspace:GetDescendants()) do if (Part:IsA 'BasePart') and (Part.Material == Enum.Material.Neon) then Part.Color = Color3.new(1) end end
Finally, my wifi did not let me update the post, basically, Material
is property of BasePart
and using ==
you check if the material is given material, then you just set Color
of the part which Color3
is for, Color3.new
creates new color from 3 arguments.
BROOOOOO i can't even reload this site uhhh, sorry, i will explain it finnaly
GetDescendants is a function of an Instance
which returns all instances that are located in given instance, not only children but also children of the children and children of the children of the children... ipairs is a loop which i guess you know what does, ipairs
is same as pairs
but ipairs
breaks if 1. Index is not a number 2. Value is nil, it's also faster than pairs.