Hi! I created a script that allows the ability to enable/disable themes. Is there any way of improving my mess? Are module scripts best for compacting it? Here’s my current script to show you:
The current code is for a game teleporting feature which I created and I keep updating it
local Front = script.Parent.Parent.Parent:WaitForChild("Front")
local Background = script.Parent.Parent.Parent.Parent:WaitForChild("Background")
local Bar = Background:WaitForChild("Bar")
local GameSelections = script.Parent.Parent:WaitForChild("GameSelections")
local FrontLayer = Front:WaitForChild("Front")
local Shadows = {}
local ShadowSettings = {ShadowsEnabled = false}
local function AddShadows()
for _,shadow in ipairs(Front:GetChildren()) do
if shadow:IsA("Frame") and shadow.Name == "Shadow" then
table.insert(Shadows, shadow)
end
end
end
local theme = workspace.Theme.Value
if theme == "DarkMode" then
Bar.BackgroundColor3 = Color3.fromRGB(11,11,11)
Background.BackgroundColor3 = Color3.fromRGB(31,31,31)
Front.BackgroundColor3 = Color3.fromRGB(46,46,46)
FrontLayer.BackgroundColor3 = Color3.fromRGB(46,46,46)
if theme == "LightMode" then
Front.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Bar.BackgroundColor3 = Color3.fromRGB(15, 139, 255)
Background.BackgroundColor3 = Color3.fromRGB(226, 226, 226)
FrontLayer.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
end
for _,text in ipairs(Front:GetChildren()) do
if text:IsA("TextLabel") and text.Name ~= "Ratings" then
text.TextColor3 = Color3.fromRGB(255,255,255)
if theme == "LightMode" then
text.TextColor3 = Color3.fromRGB(0,0,0)
end
end
for _,button in ipairs(GameSelections:GetChildren()) do
if button:IsA("TextButton") then
button.BackgroundColor3 = Color3.fromRGB(46,46,46)
button.TextColor3 = Color3.fromRGB(255,255,255)
if theme == "LightMode" then
button.BackgroundColor3 = Color3.fromRGB(255,255,255)
button.TextColor3 = Color3.fromRGB(0,0,0)
end
end
end
end
end
AddShadows()
for _,shadow in ipairs(Shadows) do
if shadow:IsA("Frame") and shadow.Name == "Shadow" then
shadow.Visible = ShadowSettings.ShadowsEnabled
end
end
I don’t like how the current script is, because if I ever created a whole new UI page with features. Then it won’t match up with the rest of the UI without making more scripts.
UI Design
My current design for this, very much like the Roblox website but I’m keeping at it to keep things cool
Edit: I’m revamping the UI so it doesn’t copy the same UI as the website and makes it boring.
gyazo.com/5225f251b70b5baaf9e1a48a5e25828d
Light theme in action: