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
5 years ago
Edited 5 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:

-- Color

    local DarkerBlue = 53,56,255

    local LighterBlue = 101,103,255



-- Elements

local FrameD1 = script.Parent.Parent

local FrameD2 = script.Parent.Parent.Parent.Universo

local FrameL1 = script.Parent.Parent.inside

local FrameL2 = script.Parent.Parent.Parent.Universo.About

local FrameL3 = script.Parent.Parent.Parent.Universo.Games

local FrameL4 = script.Parent.Parent.Parent.Universo.Home

local FrameL5 = script.Parent.Parent.Parent.Universo.Settings

local DButton1 = script.Parent.Parent.Parent.Universo.Home.Btools

local DButton2 = script.Parent.Parent.Parent.Universo.Home.FlingM

local DButton3 = script.Parent.Parent.Parent.Universo.Home.KillM

local DButton4 = script.Parent.Parent.Parent.Universo.Home.FlyOFF

local DButton5 = script.Parent.Parent.Parent.Universo.Home.FlyON

local DButton6 = script.Parent.Parent.Parent.Universo.Home.NoColideON

local DButton7 = script.Parent.Parent.Parent.Universo.Home.NoColideOFF

local DButton8 = script.Parent.Parent.Parent.Universo.Home.Nohat

local DButton9 = script.Parent.Parent.Parent.Universo.Home.JHBox

local DButton10 = script.Parent.Parent.Parent.Universo.Home.JHSet

local DButton11 = script.Parent.Parent.Parent.Universo.Home.WSBox

local DButton12 = script.Parent.Parent.Parent.Universo.Home.WSSet

local DButton13 =script.Parent.Blue

local DButton14 =script.Parent.Darkmode

local DButton15 =script.Parent.Green

local DButton16 =script.Parent.Lightmode

local DButton17 =script.Parent.Orange

local DButton18 =script.Parent.Purple

local DButton19 =script.Parent.Red

local DButton20 =script.Parent.Yellow

local DButton21 = script.Parent.Parent.Parent.Universo.Settings.Delte

local DButton22 = script.Parent.Parent.Parent.Universo.Settings.DragRepair

local DButton23 = script.Parent.Parent.Parent.Universo.Settings.OPBox

local DButton24 = script.Parent.Parent.Parent.Universo.Settings.OPSet

local DButton25 = script.Parent.Parent.Parent.Universo.Settings.Themes

local DButton26 = script.Parent.Parent.Parent.Universo.Settings.Update

local LButton1 = script.Parent.Parent.Parent.Universo.AboutB

local LButton2 = script.Parent.Parent.Parent.Universo.GamesB

local LButton3 = script.Parent.Parent.Parent.Universo.HomeB

local LButton4 = script.Parent.Parent.Parent.Universo.SettingsB



script.Parent.Blue.MouseButton1Click:Connect(function()



FrameD1.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

FrameD2.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton1.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton2.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton3.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton4.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton5.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton6.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton7.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton8.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton9.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton10.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton11.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton12.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton13.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton14.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton15.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton16.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton17.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton18.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton19.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton20.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton21.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton22.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton23.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton24.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton25.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

DButton26.BackgroundColor3 = Color3.new(Color3.fromRGB(DarkerBlue))

FrameL1.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

FrameL2.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

FrameL3.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

FrameL4.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

FrameL5.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

LButton1.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

LButton2.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

LButton3.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

LButton4.BackgroundColor3 = Color3.new(Color3.fromRGB(LighterBlue))

end)

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 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:

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

So instead of

Color3.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 — 5y
Ad

Answer this question