Changing multiple parts BrickColor at the same time

Hi, I am newish to scripting and am currently trying to change multiple parts.BrickColor at the same time, within the same model. I have tried both a for loop and a while loop and while the for loop works but changes them independantly the while loop doesn’t work at all. Here are both samples of code I have used. Any help would be much appreciated.

local CollectionService = game:GetService("CollectionService")

local Tagged = CollectionService:GetTagged("weaponBlock")

repeat
	for i, object in pairs(Tagged) do
		
		if object and object.BrickColor then
			
			object.BrickColor = BrickColor.new("Really red")
			wait()
			object.BrickColor = BrickColor.new("Bright blue")
			wait()
			object.BrickColor = BrickColor.new("New Yeller")
			wait()
			object.BrickColor = BrickColor.new("Bright green")
			wait()
			
		end
		
end
until script.Disabled == true
local CollectionService = game:GetService("CollectionService")

local Tagged = CollectionService:GetTagged("weaponBlock")
local object = Tagged

while script.Disabled == false do
		
		if object and object.BrickColor then
			
			object.BrickColor = BrickColor.new("Really red")
			wait()
			object.BrickColor = BrickColor.new("Bright blue")
			wait()
			object.BrickColor = BrickColor.new("New Yeller")
			wait()
			object.BrickColor = BrickColor.new("Bright green")
			wait()
			
	end
	wait()
		
end

Again thank you for any help

3 Likes

So if I’m understanding correctly, you want to change the color at the exact same time rather than waiting 1/30th of a second between each color change.

To accomplish running two things at the same time, use couratines. If you’re unaware of coroutine, dev king has a good tutorial on them

1 Like

No, I want to change each part at the same time not the colors at the same time. Sorry for any confusion.

If your goal is have all the model change color at the same time together, you could union the model and input the script there.

The while loop? Will give it a go now. Thanks

slightly unrelated but if you want to make script.Disabled stop your script without needing an extra loop, you can do something like this:

script:GetPropertyChangedSignal("Disabled"):Connect(function()
    if script.Disabled then
        coroutine.yield()
    end
end)

-- rest of the code here

the coroutine.yield() will pause the execution of the script.

Tried both a for loop and a while loop, the while loop didn’t work and while the for loop worked for the properties physically they didn’t change. Thanks though

1 Like

the script. Disabled is just there as round stop so I think its good, thanks though will keep it in mind for other projects

1 Like