Trouble using Color3 Values?
I was making a GUI script for my RPG, which basically makes it so that I have 3 NumberValues
:
ColourRValue
ColourBValue
ColourGValue
I wanted to make a script where if you change any of the values, it will change the GUI buttons' BackgroundColor3
value. The problem is, Color3 values don't work up to 255, so I had to divide it by 255. This is where my problem comes in. I divided it but the script doesn't work. Here is my code
01 | local player = script.Parent.Parent.Parent.Parent |
02 | local character = player.Character or player.CharacterAdded:wait() |
03 | local colourR = script.Parent.ColourRValue |
04 | local colourG = script.Parent.ColourGValue |
05 | local colourB = script.Parent.ColourBValue |
06 | local newColourR = colourR.Value / 255 |
07 | local newColourG = colourG.Value / 255 |
08 | local newColourB = colourB.Value / 255 |
10 | local tut = script.Parent.TutButton |
11 | local stats = script.Parent.StatsButton |
12 | local skills = script.Parent.SkillsButton |
13 | local inv = script.Parent.InvButton |
14 | local settings = script.Parent.SettingsButton |
16 | colourR.Changed:connect( function () |
17 | local newColourR = colourR.Value / 255 |
18 | local newColourG = colourG.Value / 255 |
19 | local newColourB = colourB.Value / 255 |
21 | colourG.Changed:connect( function () |
22 | local newColourR = colourR.Value / 255 |
23 | local newColourG = colourG.Value / 255 |
24 | local newColourB = colourB.Value / 255 |
26 | colourB.Changed:connect( function () |
27 | local newColourR = colourR.Value / 255 |
28 | local newColourG = colourG.Value / 255 |
29 | local newColourB = colourB.Value / 255 |
32 | newColourR.Changed:connect( function () |
34 | tut.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
35 | stats.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
36 | skills.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
37 | inv.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
38 | settings.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
40 | tut.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
41 | stats.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
42 | skills.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
43 | inv.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
44 | settings.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
48 | newColourG.Changed:connect( function () |
50 | tut.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
51 | stats.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
52 | skills.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
53 | inv.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
54 | settings.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
56 | tut.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
57 | stats.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
58 | skills.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
59 | inv.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
60 | settings.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
64 | newColourB.Changed:connect( function () |
66 | tut.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
67 | stats.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
68 | skills.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
69 | inv.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
70 | settings.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
72 | tut.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
73 | stats.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
74 | skills.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
75 | inv.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
76 | settings.TextLabel.BackgroundColor 3 = Color 3. new(newColourR, newColourG, newColourB) |
And my error: 11:51:31.696 - Players.Player1.PlayerGui.ScreenGui.Frame.Colour:32: attempt to index local 'newColourR' (a number value)
Also, the hierarchy: https://gyazo.com/f3de31f100dc10720bb25cc008259819
Thanks for your help!