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

How to change the colour of multiple frames at once?

I was thinking maybe making a table of all frames/buttons and then have them all change colour at once. I want to make themes for a GUI, and that includes changing colour of all frames, text buttons, text labels etc, is there any way to do something like table_for_buttons.BackgroundColor = colour or something like that to change all of the buttons colours at once?

2 answers

✓ Accepted answer

just a base to run from, but you are on the right track from your post. Here's a snip to get you started


local stuff = someGUI:GetChildren() -- GetChildren() creates a table of all objects that have someGUI as it's parent. So stuff is now our table

for i,v in pairs(stuff) do -- loop through da table and change the objects (v) backgroundcolor
	v.BackgroundColor3 = Color3.fromRGB(0,0,0)
end

There is this cool loop.... You can use, it is called a for loop, here is an example

local PlaceWhereAllButtonsAreKept -- you must define this, must be parent of button

for ThisIsA, ForLoop in pairs(PlaceWhereAllButtonsAreKept:GetChildren()) do 
	if ForLoop.ClassName == "TextButton" or "TextLabel" then
		-- Now you can add the colors... randomized colors...
	end
end

Untested! But for loops literally changes multiple stuff, Have fun, BAIII

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