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

how do i make this script change color for all parts?

i have a folder in workspace called "Spotlights" and in them is my models all named the same: "Spotlight_1" and in them i have a part and in the part i have the beam. how can i change colors for all the "Spotlight_1 " models?

while true do
    script.Parent.Color = ColorSequence.new(Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255)),Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255))) 
    wait(1)
end

2 comments

0

dont help

1 answer

I'm on my phone so I can't test if this works, but you could use a for i, v in pairs to find every child of the "Spotlights" folder and change their color

while true do
	for i, v in pairs(workspace.Spotlights:GetChildren()) do
		local beam = v.Part.Beam
		if beam then
			beam.Color = ColorSequence.new(Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255)),Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255))) 
    		wait(1)
		end
	end
end

5 comments

0

not working :( ok so look i have afolder "spotlights" in that is the models "Spotlight_1" and in all of those same "Spotlight_1" models is a model called "Body" in body there is a "Head" model and in that head is a part called "beam" in the beam part is the actual beam so ye what do i do

0

Oh okay, if I'm understanding you correctly then this might work

0

Try the edited script out

0

but the beam isnt just in the spotlight_1 its in the models inside spotlight_! called "Body"

0

so just change the line 3 to the object path of the beam, so it would be something like "local beam = v.Body.Head.beam.Beam"

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