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

Is there a way to change the color of multiple blocks in just one string?

The title pretty much says it all but, say if I didn't want to type out each one.

Something like this:

a = game.Workspace.Part1,Part2,Part3

a.BrickColor = BrickColor.new(1004) 

I know that script would not work but is there any way like it?

I don't really care to type it out like this:

a = game.Workspace.Part1
b = game.Workspace.Part2
c = game.Workspace.Part3

a.BrickColor = BrickColor.new(1004)
b.BrickColor = BrickColor.new(1004)
c.BrickColor = BrickColor.new(1004)


I've got 88 parts that I need to change the color 24 times.

Thanks, Bb1

1 comment

0

A general tip: Use brick color names as the parameter to BrickColor.new instead of the number. It makes it a lot easier to read and figure out!

2 answers

✓ Accepted answer

You could make a function to change the color of all the parts.

local parts = Workspace.Model -- Location of parts

function setColor(color)
	for _, p in pairs(parts:GetChildren()) do
		p.BrickColor = BrickColor.new(color)
	end
end

-- example
while true do
	setColor("Bright red")
	wait(20)
	setColor("Bright blue")
	wait(40)
end

1 comment

0

Thank you very much! I found yours the most helpful and it works.

Well, yes. If you wouldn't mind grouping them all together, then it'll be possible to do it all in less lines. You'd need to use either the generic for loop or the numeric for loop. I'll use the generic.

Model = game.Workspace["Model"]:GetChildren() -- You can obviously change the name to your liking.

for i,v in pairs(Model) do
	v.BrickColor = BrickColor.new(1004)
	wait(1)
	v.BrickColor = BrickColor.new(1003) -- Really black
end

2 comments

0

Thank You, I'm going to test this right now.

0

No problem.

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