Multiple color changing bricks scripting

Hello!

I have created a script that changes the color of every part named “H” that is it’s child although it sort of works it doesn’t work how I had expected.

Instead of changing all the colors at the same time it does it one by one which creates a weird pattern originally I wanted them to all change at the same time.

Can somebody please help me achieve this?

Here is the script I am using

while true do
	wait(0.1)
	if game.lighting:GetMinutesAfterMidnight() > 6 * 60 then
		local children = script.Parent:GetChildren()
		for c = 1, #children do
			if children[c].Name == "H" then
				children[c].Color = Color3.fromHSV(0, 1, 0.776471)
				wait(0.1)
				children[c].Color = Color3.fromHSV(0.416333, 1, 1)
				wait(0.1)
				children[c].Color = Color3.fromHSV(0.166667, 1, 1)
				wait(0.1)
				children[c].Color = Color3.fromHSV(0.917, 1, 1)
				wait(0.1)
				children[c].Color = Color3.fromHSV(0.594778, 1, 1)
			end
			end
		end
	end

The script could be awful but its the best I can do as of now lol

Appreicate anybody that helps out!

1 Like

Hi there, this would probably work!

local children = script.Parent:GetChildren()
for c = 1, #children do
if children[c].Name == "H" then
	while wait(0.1) do
		if game.lighting:GetMinutesAfterMidnight() > 6 * 60 then
				children[c].Color = Color3.fromHSV(0, 1, 0.776471)
				wait(0.1)
				children[c].Color = Color3.fromHSV(0.416333, 1, 1)
				wait(0.1)
				children[c].Color = Color3.fromHSV(0.166667, 1, 1)
				wait(0.1)
				children[c].Color = Color3.fromHSV(0.917, 1, 1)
				wait(0.1)
				children[c].Color = Color3.fromHSV(0.594778, 1, 1)
			end
		end
	end
end 

I have tried the script unfortunately it only changes the color of one brick in the entire model.

I’ll see if I can edit it a little bit and get it to work.

Oh I am sorry i forgot to add spawn(function()

I’ve added it in and its working perfectly now. Thank you!