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

Using scripts to select multiple bricks?

Asked by 8 years ago

Here is the simple script: game.Workspace.Part.BrickColor = BrickColor.new

So lets say all the bricks in Workspace are all named "Part". Why does the script only change the color of one of the Bricks ? Is this a solvable problem?

0
The button to select a post as an answer ("Mark as Answer") is below the username of the poster (above the "Report to Staff" button) chess123mate 5873 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago

You'd be able to select all of the parts that are named Part in the workspace by iterating through all of the parts that are named Part. Here is an example:

for i,v in next, game.Workspace:GetChildren() do
if v.Name == "Part" and v.ClassName == "Part" then
v.BrickColor = BrickColor.new(--desired brick color in a string--)
end
end

I hope I helped!

0
Thank you so so so much. My new plugin script finaly works. I cant thank you enough. I would love to pay you for this maxenator 0 — 8y
0
Im not to sure how to put this question as awnsered... darn it maxenator 0 — 8y
0
Yeah, i'm new so I dont know how either. I sent you a friend request, my account is applyed. The only reason it is not applyed on here is because I got terminated 2 years ago from people constantly downvoting me when i gave correct answers CubicleCurse 5 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

To select multiple bricks, you will need to use a loop.

Just like the other guy said.

for _,Part in next, (game.Workspace:GetChildren()) do -- Gets all items in workspace
    if (Part .Name == "Part") and Part :IsA("BasePart")  then -- Checks if the name is "Part" and if the item is actually a basepart. I prefer using ':IsA' than checking for the ClassName.
        Part .BrickColor = BrickColor.new("Really red") -- Random example, note: Colors are cap sensitive, you have to spell it properly
    end
end

Answer this question