(No one replied to my last post so I am posting it again) As the title says i want you guys to see if this is a bad way of doing this and if there is a better way of optimizing it
(Each slot is for a different setting btw)
for _, settingUis in SettingUi:GetChildren() do
if settingUis:IsA("Frame") then
if settingUis.Name == "Slot1" then
settingUis.SwitchFrame.SwitchButton.Activated:Connect(function()
if Configs.Value.Value == false then
GuiController.Slide(SettingUi.Slot1.SwitchFrame.SwitchButton, "Off")
SettingUi.Slot1.SwitchFrame.BackgroundColor = BrickColor.new("Really red")
SettingUi.Slot1.SwitchFrame.SwitchButton.BackgroundColor = BrickColor.new("Crimson")
Configs.Value.Value = true
else
GuiController.Slide(SettingUi.Slot1.SwitchFrame.SwitchButton, "On")
SettingUi.Slot1.SwitchFrame.BackgroundColor = BrickColor.new("Lime green")
SettingUi.Slot1.SwitchFrame.SwitchButton.BackgroundColor = BrickColor.new("Forest green")
Configs.Value.Value = false
end
end)
end
end
if settingUis.Name == "Slot2" then
settingUis.SwitchFrame.SwitchButton.Activated:Connect(function()
if Configs.Value.Value == false then
GuiController.Slide(SettingUi.Slot2.SwitchFrame.SwitchButton, "Off")
SettingUi.Slot2.SwitchFrame.BackgroundColor = BrickColor.new("Really red")
SettingUi.Slot2.SwitchFrame.SwitchButton.BackgroundColor = BrickColor.new("Crimson")
Configs.Value.Value = true
else
GuiController.Slide(SettingUi.Slot2.SwitchFrame.SwitchButton, "On")
SettingUi.Slot2.SwitchFrame.BackgroundColor = BrickColor.new("Lime green")
SettingUi.Slot2.SwitchFrame.SwitchButton.BackgroundColor = BrickColor.new("Forest green")
Configs.Value.Value = false
end
end)
end
if settingUis.Name == "Slot3" then
settingUis.SwitchFrame.SwitchButton.Activated:Connect(function()
if Configs.Value.Value == false then
GuiController.Slide(SettingUi.Slot3.SwitchFrame.SwitchButton, "Off")
SettingUi.Slot3.SwitchFrame.BackgroundColor = BrickColor.new("Really red")
SettingUi.Slot3.SwitchFrame.SwitchButton.BackgroundColor = BrickColor.new("Crimson")
Configs.Value.Value = true
else
GuiController.Slide(SettingUi.Slot3.SwitchFrame.SwitchButton, "On")
SettingUi.Slot3.SwitchFrame.BackgroundColor = BrickColor.new("Lime green")
SettingUi.Slot3.SwitchFrame.SwitchButton.BackgroundColor = BrickColor.new("Forest green")
Configs.Value.Value = false
end
end)
end
end