Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Using scripts to select multiple bricks?

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?

1 comment

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)

2 answers

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!

3 comments

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

0

Im not to sure how to put this question as awnsered... darn it

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.