I’m trying to make a script that changes the GUI’s Theme between Light, Dark and Transparent. I’m just worried it’s too chunky and might slow down the game. Will it really slow down the game? If so, is there a better way of doing this?
Setting tags
for i, obj in pairs(frame.Setting:GetDescendants()) do
if obj:IsA("TextLabel") then
if frame.Setting:FindFirstChild(obj.Name) then tagService:AddTag(obj, "settingName") end
elseif obj:IsA("TextButton") then
for i, ins in pairs(tagService:GetTagged("settingName")) do
if obj:IsDescendantOf(ins) then
tagService:AddTag(obj, "settingButton")
end
end
elseif obj:IsA("Frame") then
for i, ins in pairs(tagService:GetTagged("settingButton")) do
if obj:IsDescendantOf(ins) then
tagService:AddTag(obj, "buttonFrame")
end
end
end
end```
**Changing theme**
```lua
for _, b in pairs(options:GetChildren()) do
if b:IsA("TextButton") then
b.MouseButton1Click:Connect(function()
if optionsOn == true then
button.Text = b.Text
game:GetService("ReplicatedStorage").SettingsRemote:FireServer(b.Text)
local settingNames = tagService:GetTagged("settingName")
local settingButtons = tagService:GetTagged("settingButton")
local buttonFrames = tagService:GetTagged("buttonFrame")
if b.Text == "Light" then
frame.BackgroundColor3 = Color3.fromRGB(255,255,255)
frame.BackgroundTransparency = 0
for _, obj in pairs(settingNames) do
obj.TextColor3 = Color3.fromRGB(0,0,0)
obj.TextTransparency = 0.3
obj.BackgroundTransparency = 1
end
for _, obj in pairs(settingButtons) do
obj.TextColor3 = Color3.fromRGB(0,0,0)
obj.TextTransparency = 0.5
obj.BackgroundTransparency = 0
obj.BackgroundColor3 = Color3.fromRGB(220,220,220)
end
for _, obj in pairs(buttonFrames) do
obj.BackgroundTransparency = 0
obj.BackgroundColor3 = Color3.fromRGB(210,210,210)
end
elseif b.Text == "Dark" then
frame.BackgroundColor3 = Color3.fromRGB(51,51,51)
frame.BackgroundTransparency = 0
for _, obj in pairs(settingNames) do
obj.TextColor3 = Color3.fromRGB(255,255,255)
obj.TextTransparency = 0.3
obj.BackgroundTransparency = 1
end
for _, obj in pairs(settingButtons) do
obj.TextColor3 = Color3.fromRGB(255,255,255)
obj.TextTransparency = 0.5
obj.BackgroundTransparency = 0
obj.BackgroundColor3 = Color3.fromRGB(74,74,74)
end
for _, obj in pairs(buttonFrames) do
obj.BackgroundTransparency = 0
obj.BackgroundColor3 = Color3.fromRGB(80,80,80)
end
elseif b.Text == "Transparent" then
frame.BackgroundColor3 = Color3.fromRGB(255,255,255)
frame.BackgroundTransparency = 1
for _, obj in pairs(settingNames) do
obj.TextColor3 = Color3.fromRGB(255,255,255)
obj.TextTransparency = 0.1
obj.BackgroundTransparency = 1
end
for _, obj in pairs(settingButtons) do
obj.TextColor3 = Color3.fromRGB(255,255,255)
obj.TextTransparency = 0
obj.BackgroundTransparency = 0.8
obj.BackgroundColor3 = Color3.fromRGB(255,255,255)
end
for _, obj in pairs(buttonFrames) do
obj.BackgroundTransparency = 0.9
obj.BackgroundColor3 = Color3.fromRGB(255,255,255)
end
end
end
end)
end
end```
Thank you