Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to get all neon parts in the workspace?

Asked by 4 years ago
Edited 4 years ago

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
0
There definitely is, but please make and post an attempt before asking for a script. DinozCreates 1070 — 4y
0
Alright TheStarWarsMaster856 12 — 4y

1 answer

Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago
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.

Ad

Answer this question