So I wanted to make a theme and when you clicked the button it would change everything into a blue theme. But instead of changing everything into a light blue and dark blue combination everything turns black. Can anyone tell me why?
The following code is a part of the theme menu that would change color of a admin GUI on my experimental game.
My code:
001 | -- Color |
002 | |
003 | local DarkerBlue = 53 , 56 , 255 |
004 | |
005 | local LighterBlue = 101 , 103 , 255 |
006 | |
007 | |
008 |
009 | -- Elements |
010 |
011 | local FrameD 1 = script.Parent.Parent |
012 |
013 | local FrameD 2 = script.Parent.Parent.Parent.Universo |
014 |
015 | local FrameL 1 = script.Parent.Parent.inside |
016 |
017 | local FrameL 2 = script.Parent.Parent.Parent.Universo.About |
018 |
019 | local FrameL 3 = script.Parent.Parent.Parent.Universo.Games |
020 |
021 | local FrameL 4 = script.Parent.Parent.Parent.Universo.Home |
022 |
023 | local FrameL 5 = script.Parent.Parent.Parent.Universo.Settings |
024 |
025 | local DButton 1 = script.Parent.Parent.Parent.Universo.Home.Btools |
026 |
027 | local DButton 2 = script.Parent.Parent.Parent.Universo.Home.FlingM |
028 |
029 | local DButton 3 = script.Parent.Parent.Parent.Universo.Home.KillM |
030 |
031 | local DButton 4 = script.Parent.Parent.Parent.Universo.Home.FlyOFF |
032 |
033 | local DButton 5 = script.Parent.Parent.Parent.Universo.Home.FlyON |
034 |
035 | local DButton 6 = script.Parent.Parent.Parent.Universo.Home.NoColideON |
036 |
037 | local DButton 7 = script.Parent.Parent.Parent.Universo.Home.NoColideOFF |
038 |
039 | local DButton 8 = script.Parent.Parent.Parent.Universo.Home.Nohat |
040 |
041 | local DButton 9 = script.Parent.Parent.Parent.Universo.Home.JHBox |
042 |
043 | local DButton 10 = script.Parent.Parent.Parent.Universo.Home.JHSet |
044 |
045 | local DButton 11 = script.Parent.Parent.Parent.Universo.Home.WSBox |
046 |
047 | local DButton 12 = script.Parent.Parent.Parent.Universo.Home.WSSet |
048 |
049 | local DButton 13 = script.Parent.Blue |
050 |
051 | local DButton 14 = script.Parent.Darkmode |
052 |
053 | local DButton 15 = script.Parent.Green |
054 |
055 | local DButton 16 = script.Parent.Lightmode |
056 |
057 | local DButton 17 = script.Parent.Orange |
058 |
059 | local DButton 18 = script.Parent.Purple |
060 |
061 | local DButton 19 = script.Parent.Red |
062 |
063 | local DButton 20 = script.Parent.Yellow |
064 |
065 | local DButton 21 = script.Parent.Parent.Parent.Universo.Settings.Delte |
066 |
067 | local DButton 22 = script.Parent.Parent.Parent.Universo.Settings.DragRepair |
068 |
069 | local DButton 23 = script.Parent.Parent.Parent.Universo.Settings.OPBox |
070 |
071 | local DButton 24 = script.Parent.Parent.Parent.Universo.Settings.OPSet |
072 |
073 | local DButton 25 = script.Parent.Parent.Parent.Universo.Settings.Themes |
074 |
075 | local DButton 26 = script.Parent.Parent.Parent.Universo.Settings.Update |
076 |
077 | local LButton 1 = script.Parent.Parent.Parent.Universo.AboutB |
078 |
079 | local LButton 2 = script.Parent.Parent.Parent.Universo.GamesB |
080 |
081 | local LButton 3 = script.Parent.Parent.Parent.Universo.HomeB |
082 |
083 | local LButton 4 = script.Parent.Parent.Parent.Universo.SettingsB |
084 |
085 |
086 |
087 | script.Parent.Blue.MouseButton 1 Click:Connect( function () |
088 |
089 | |
090 |
091 | FrameD 1. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
092 |
093 | FrameD 2. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
094 |
095 | DButton 1. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
096 |
097 | DButton 2. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
098 |
099 | DButton 3. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
100 |
101 | DButton 4. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
102 |
103 | DButton 5. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
104 |
105 | DButton 6. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
106 |
107 | DButton 7. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
108 |
109 | DButton 8. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
110 |
111 | DButton 9. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
112 |
113 | DButton 10. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
114 |
115 | DButton 11. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
116 |
117 | DButton 12. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
118 |
119 | DButton 13. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
120 |
121 | DButton 14. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
122 |
123 | DButton 15. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
124 |
125 | DButton 16. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
126 |
127 | DButton 17. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
128 |
129 | DButton 18. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
130 |
131 | DButton 19. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
132 |
133 | DButton 20. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
134 |
135 | DButton 21. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
136 |
137 | DButton 22. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
138 |
139 | DButton 23. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
140 |
141 | DButton 24. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
142 |
143 | DButton 25. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
144 |
145 | DButton 26. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(DarkerBlue)) |
146 |
147 | FrameL 1. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
148 |
149 | FrameL 2. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
150 |
151 | FrameL 3. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
152 |
153 | FrameL 4. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
154 |
155 | FrameL 5. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
156 |
157 | LButton 1. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
158 |
159 | LButton 2. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
160 |
161 | LButton 3. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
162 |
163 | LButton 4. BackgroundColor 3 = Color 3. new(Color 3. fromRGB(LighterBlue)) |
164 |
165 | end ) |
Instead of trying to make a new color3 for every line, you should instead make the color3 where you define your variables. Also RGB color3s can only take values between 0 and 1, so you should divide all numbers by 255, like:
1 | local DarkerBlue = Color 3. new( 53 / 255 , 56 / 255 , 255 / 255 ) |
2 | local LighterBlue = Color 3. new( 101 / 255 , 103 / 255 , 255 / 255 ) |
So instead of
1 | Color 3. new(Color 3. fromRGB()) |
you should use the new variables you just defined. You can also greatly reduce the amount of lines of code you have by using loops. More info on loops here: https://developer.roblox.com/articles/Roblox-Coding-Basics-Loops
Hope this helps!