Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my set color button not work and turn everything black?

Asked by
Lualaxy 78
6 years ago
Edited 6 years ago

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 
011local FrameD1 = script.Parent.Parent
012 
013local FrameD2 = script.Parent.Parent.Parent.Universo
014 
015local FrameL1 = script.Parent.Parent.inside
016 
017local FrameL2 = script.Parent.Parent.Parent.Universo.About
018 
019local FrameL3 = script.Parent.Parent.Parent.Universo.Games
020 
021local FrameL4 = script.Parent.Parent.Parent.Universo.Home
022 
023local FrameL5 = script.Parent.Parent.Parent.Universo.Settings
024 
025local DButton1 = script.Parent.Parent.Parent.Universo.Home.Btools
026 
027local DButton2 = script.Parent.Parent.Parent.Universo.Home.FlingM
028 
029local DButton3 = script.Parent.Parent.Parent.Universo.Home.KillM
030 
031local DButton4 = script.Parent.Parent.Parent.Universo.Home.FlyOFF
032 
033local DButton5 = script.Parent.Parent.Parent.Universo.Home.FlyON
034 
035local DButton6 = script.Parent.Parent.Parent.Universo.Home.NoColideON
036 
037local DButton7 = script.Parent.Parent.Parent.Universo.Home.NoColideOFF
038 
039local DButton8 = script.Parent.Parent.Parent.Universo.Home.Nohat
040 
041local DButton9 = script.Parent.Parent.Parent.Universo.Home.JHBox
042 
043local DButton10 = script.Parent.Parent.Parent.Universo.Home.JHSet
044 
045local DButton11 = script.Parent.Parent.Parent.Universo.Home.WSBox
046 
047local DButton12 = script.Parent.Parent.Parent.Universo.Home.WSSet
048 
049local DButton13 =script.Parent.Blue
050 
051local DButton14 =script.Parent.Darkmode
052 
053local DButton15 =script.Parent.Green
054 
055local DButton16 =script.Parent.Lightmode
056 
057local DButton17 =script.Parent.Orange
058 
059local DButton18 =script.Parent.Purple
060 
061local DButton19 =script.Parent.Red
062 
063local DButton20 =script.Parent.Yellow
064 
065local DButton21 = script.Parent.Parent.Parent.Universo.Settings.Delte
066 
067local DButton22 = script.Parent.Parent.Parent.Universo.Settings.DragRepair
068 
069local DButton23 = script.Parent.Parent.Parent.Universo.Settings.OPBox
070 
071local DButton24 = script.Parent.Parent.Parent.Universo.Settings.OPSet
072 
073local DButton25 = script.Parent.Parent.Parent.Universo.Settings.Themes
074 
075local DButton26 = script.Parent.Parent.Parent.Universo.Settings.Update
076 
077local LButton1 = script.Parent.Parent.Parent.Universo.AboutB
078 
079local LButton2 = script.Parent.Parent.Parent.Universo.GamesB
080 
081local LButton3 = script.Parent.Parent.Parent.Universo.HomeB
082 
083local LButton4 = script.Parent.Parent.Parent.Universo.SettingsB
084 
085 
086 
087script.Parent.Blue.MouseButton1Click:Connect(function()
088 
089   
090 
091FrameD1.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
092 
093FrameD2.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
094 
095DButton1.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
096 
097DButton2.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
098 
099DButton3.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
100 
101DButton4.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
102 
103DButton5.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
104 
105DButton6.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
106 
107DButton7.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
108 
109DButton8.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
110 
111DButton9.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
112 
113DButton10.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
114 
115DButton11.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
116 
117DButton12.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
118 
119DButton13.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
120 
121DButton14.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
122 
123DButton15.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
124 
125DButton16.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
126 
127DButton17.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
128 
129DButton18.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
130 
131DButton19.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
132 
133DButton20.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
134 
135DButton21.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
136 
137DButton22.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
138 
139DButton23.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
140 
141DButton24.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
142 
143DButton25.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
144 
145DButton26.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))
146 
147FrameL1.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
148 
149FrameL2.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
150 
151FrameL3.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
152 
153FrameL4.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
154 
155FrameL5.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
156 
157LButton1.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
158 
159LButton2.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
160 
161LButton3.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
162 
163LButton4.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))
164 
165end)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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:

1local DarkerBlue = Color3.new(53/255 ,56/255 ,255/255)
2local LighterBlue = Color3.new(101/255, 103/255, 255/255)

So instead of

1Color3.new(Color3.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!

0
Thank you very much for the solution! Lualaxy 78 — 6y
Ad

Answer this question