Im making it so it changes the background color to a dark/light mode. I cant figure out how to do it, also if you have any suggestions for it comment below.
edit:
i figured it out, but how should i improve it?
If you’re purely looking for feedback on how to improve it design wise, this is the wrong category. Try posting your creation in the Cool Creations category.
I have it scripted, im asking how to improve the script. Which can be found here:
I suggest having a table with all of your gui elements you’d like to change. Loop through the table and set the background color to a predefined color. An example is below.
local guiElementsTable = {}; -- our gui elements table
local playerInstance = game:GetService("Players").LocalPlayer;
local lightColor = Color3.new(); -- light color here
local darkColor = Color3.new(); -- dark color here
for _, element in pairs(playerInstance.PlayerGui.Background2:GetChildren()) do
-- should also check to make sure element is a frame, text label, etc
table.insert(guiElementsTable, #guiElementsTable+1, element); -- add the element to the table
end
local lightMode = function()
for _, element in pairs(guiElementsTable) do
element.BackgroundColor3 = lightColor;
end
end
local darkMode = function()
for _, element in pairs(guiElementsTable) do
element.BackgroundColor3 = darkColor;
end
end
Using the 2nd one allows for you to use the rgb color code, so basically you could do Color3.fromRGB(1, 1, 1)
And it will do 1 of each color, doing a really dark black