Toggle Gui Not Working

Hey DevForums! So I made this little toggle gui script, but it seems to not work properly. It changes the text, but not the color. I’ve checked output, and nothing seems to be wrong. Thanks.

Script:

local gui = script.Parent
local menu = gui.Parent.Parent

gui.MouseButton1Click:Connect(function()
if script.Value.Value == false then
gui.Text = “Light Mode”
menu.MapVote.BackgroundColor3 = Color3.new(191, 191, 191)
menu.Select.BackgroundColor3 = Color3.new(191, 191, 191)
menu.SettingsMenu.BackgroundColor3 = Color3.new(191, 191, 191)
gui.BackgroundColor3 = Color3.new(191, 191, 191)
menu.TimeVote.BackgroundColor3 = Color3.new(191, 191, 191)
menu.GamepassShop.BackgroundColor3 = Color3.new(191, 191, 191)
menu.Info.BackgroundColor3 = Color3.new(191, 191, 191)
menu.Maps.BackgroundColor3 = Color3.new(191, 191, 191)
menu.Settings.BackgroundColor3 = Color3.new(191, 191, 191)
menu.Stats.BackgroundColor3 = Color3.new(191, 191, 191)
menu.InfoButton.BackgroundColor3 = Color3.new(191, 191, 191)
menu.PLAY.BackgroundColor3 = Color3.new(191, 191, 191)
menu.ShopButton.BackgroundColor3 = Color3.new(191, 191, 191)
menu.Process.BackgroundColor3 = Color3.new(191, 191, 191)
menu.Unavailable.BackgroundColor3 = Color3.new(191, 191, 191)
script.Value.Value = true
elseif script.Value.Value == true then
gui.Text = “Dark Mode”
menu.MapVote.BackgroundColor3 = Color3.new(57, 57, 57)
menu.Select.BackgroundColor3 = Color3.new(57, 57, 57)
menu.SettingsMenu.BackgroundColor3 = Color3.new(57, 57, 57)
gui.BackgroundColor3 = Color3.new(57, 57, 57)
menu.TimeVote.BackgroundColor3 = Color3.new(57, 57, 57)
menu.GamepassShop.BackgroundColor3 = Color3.new(57, 57, 57)
menu.Info.BackgroundColor3 = Color3.new(57, 57, 57)
menu.Maps.BackgroundColor3 = Color3.new(57, 57, 57)
menu.Settings.BackgroundColor3 = Color3.new(57, 57, 57)
menu.Stats.BackgroundColor3 = Color3.new(57, 57, 57)
menu.InfoButton.BackgroundColor3 = Color3.new(57, 57, 57)
menu.PLAY.BackgroundColor3 = Color3.new(57, 57, 57)
menu.ShopButton.BackgroundColor3 = Color3.new(57, 57, 57)
menu.Process.BackgroundColor3 = Color3.new(57, 57, 57)
menu.Unavailable.BackgroundColor3 = Color3.new(57, 57, 57)
script.Value.Value = false
end
end)

Please put your script in a code block so we can better read the script.

Also, you are supposed to do Color3.fromRGB(), not Color3.new(). Color3.fromRGB() accepts numbers between 0 and 255. Color3.new() accepts numbers between 0 and 1. So anything greater than 1 will be the equivalent of 1.

I’m just going to format your code so we can see it easier

local gui = script.Parent
local menu = gui.Parent.Parent

gui.MouseButton1Click:Connect(function()
       if script.Value.Value == false then
              gui.Text = “Light Mode”
              menu.MapVote.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.Select.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.SettingsMenu.BackgroundColor3 = Color3.new(191, 191, 191)
              gui.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.TimeVote.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.GamepassShop.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.Info.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.Maps.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.Settings.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.Stats.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.InfoButton.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.PLAY.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.ShopButton.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.Process.BackgroundColor3 = Color3.new(191, 191, 191)
              menu.Unavailable.BackgroundColor3 = Color3.new(191, 191, 191)
              script.Value.Value = true
       elseif script.Value.Value == true then
              gui.Text = “Dark Mode”
              menu.MapVote.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.Select.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.SettingsMenu.BackgroundColor3 = Color3.new(57, 57, 57)
              gui.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.TimeVote.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.GamepassShop.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.Info.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.Maps.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.Settings.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.Stats.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.InfoButton.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.PLAY.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.ShopButton.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.Process.BackgroundColor3 = Color3.new(57, 57, 57)
              menu.Unavailable.BackgroundColor3 = Color3.new(57, 57, 57)
              script.Value.Value = false
      end
end)

Try changing it to Color3.fromRGB(191,191,191)

It would be much easier to just make two color variables:

local color1 = Color3.fromRGB(191,191,191)
local color2 = Color3.fromRGB(57,57,57)

--then for each line do something like this
menu.Mapvote.BackgroundColor3 = color1

Since you want to change all of the guis could you also do something like this to make it simpler:


local gui = script.Parent
local menu = gui.Parent.Parent

local color1 = Color3.fromRGB(191,191,191)
local color2 = Color3.fromRGB(57,57,57)

gui.MouseButton1Click:Connect(function()
        if script.Vavlue.Value ==false then
       gui.text = "Light Mode"
       script.Value.Value = true
           for I, gui in pairs(menu:GetChildren()) do --loop through all of it's children and change the background color
           gui.BackgroundColor3 = color1
        else 
               gui.text = "Dark Mode"
       script.Value.Value = false
           for I, gui in pairs(menu:GetChildren()) do --loop through all of it's children and change the background color
           gui.BackgroundColor3 = color2
               
       end
end)
1 Like