Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to change the colour of multiple frames at once?

Asked by
trecept 367 Moderation Voter
6 years ago

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

Log in to vote
0
Answered by 6 years ago

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
Ad
Log in to vote
0
Answered by 6 years ago

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

Answer this question