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

How would I do this script in a more efficient way?

I currently have it set with all the parts numbered 1-110. Rather than going like this

game.Workspace["1"].BrickColor = BrickColor.random()
wait(.08)
game.Workspace["2"].BrickColor = BrickColor.random()
wait(.08)
game.Workspace["3"].BrickColor = BrickColor.random()
wait(.08)

Any way to do this, but much easier rather than one line for each part?

2 comments

0

Keep in mind, this is simply a glimpse of my script. It will not work, but you just need to see this part.

0

I edit my answer to fit your other questions

1 answer

✓ Accepted answer

There is! Use a for loop and repeat the process 110 times!

for i = 1,110 do
	workspace[i].BrickColor = BrickColor.Random()
	wait(0.08)
end

Hope it helps!


If it doesn't work try this one:

for i = 1,110 do
	workspace[i..""].BrickColor = BrickColor.Random()
	wait(0.08)
end


You can't do all at once, but we could make it do it really fast. First GROUP the parts

local model = workspace.Model --Model here
local tick1 = tick()

for _,part in pairs(model:GetChildren()) do
	part.BrickColor = BrickColor.Random()
end

print("It took ",,(tick1 - tick()).." seconds to change all the parts colors")

2 comments

0

My only question is, how would you also do this but index all of them at the same time?

0

Or, do it in a random order

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