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

How To Make A Script That Will Change All The Parts Called 'Test' Turn Yellow And Leave Others?

Asked by 5 years ago

How To Make A Script That Will Change All The Parts Called 'Test' Turn Yellow And Leave Others

0
where are the parts that you want to change color? do you want to look in a folder? in the workspace? royaltoe 5144 — 5y
0
Nope, Everything Is Okay Venopon 2 — 5y

1 answer

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

I am not sure where your parts are, so I am going to assume they are in the workspace. Here's how to change every part named test in the workspace yellow: Keep in mind that this will only change parts directly inside of the workspace, not parts inside parts or parts inside models.

location  = game.Workspace

--loop through all the parts in the workspace
for _, child in pairs(location:GetChildren())do

    --check to see if the item we're looking at is a part and it's name is test
    if child.Name == "Test" and child:IsA("BasePart") then

        --if it is, change the bricks color to bright yellow. 
        child.BrickColor = BrickColor.new("Bright yellow")
    end
end

If you want to look at ALL parts in the workspace, including parts inside parts or parts inside models.

location  = game.Workspace

--loop through all the parts in the workspace
for _, descendant in pairs(location:GetDescendants())do

    --check to see if the item we're looking at is a part and it's name is test
    if descendant.Name == "Test" and descendant:IsA("BasePart") then

        --if it is, change the bricks color to bright yellow. 
        descendant.BrickColor = BrickColor.new("Bright yellow")
    end
end
0
Thank You So Much Venopon 2 — 5y
0
no problem let me know if you need anymore help. you might find quicker help on scripting helper's discord:https://discordapp.com/invite/UDpAX35 it's a lot more active than the website. royaltoe 5144 — 5y
Ad

Answer this question