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
local player = script.Parent.Parent.Parent.Parent
local character = player.Character or player.CharacterAdded:wait()
local colourR = script.Parent.ColourRValue --player.leaderstat.ColourR
local colourG = script.Parent.ColourGValue --player.leaderstat.ColourG
local colourB = script.Parent.ColourBValue --player.leaderstat.ColourB
local newColourR = colourR.Value / 255
local newColourG = colourG.Value / 255
local newColourB = colourB.Value / 255
local tut = script.Parent.TutButton
local stats = script.Parent.StatsButton
local skills = script.Parent.SkillsButton
local inv = script.Parent.InvButton
local settings = script.Parent.SettingsButton
colourR.Changed:connect(function()
local newColourR = colourR.Value / 255
local newColourG = colourG.Value / 255
local newColourB = colourB.Value / 255
end)
colourG.Changed:connect(function()
local newColourR = colourR.Value / 255
local newColourG = colourG.Value / 255
local newColourB = colourB.Value / 255
end)
colourB.Changed:connect(function()
local newColourR = colourR.Value / 255
local newColourG = colourG.Value / 255
local newColourB = colourB.Value / 255
end)
newColourR.Changed:connect(function()
tut.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
stats.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
skills.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
inv.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
settings.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
tut.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
stats.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
skills.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
inv.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
settings.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
end)
newColourG.Changed:connect(function()
tut.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
stats.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
skills.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
inv.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
settings.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
tut.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
stats.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
skills.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
inv.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
settings.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
end)
newColourB.Changed:connect(function()
tut.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
stats.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
skills.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
inv.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
settings.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
tut.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
stats.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
skills.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
inv.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
settings.TextLabel.BackgroundColor3 = Color3.new(newColourR, newColourG, newColourB)
end)
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!

6 comments
Also,
local player = script.Parent.Parent.Parent.Parentshould belocal player = game.Players.LocalPlayerinstead.Should be, but doesn't have to be; it works just fine as it is (Assuming the hierarchy is as expected) . If the person isn't using FilteringEnabled then they've got the all clear to put Script objects inside of the PlayerGui to be run on the server instead.
Also, what the Asker was trying to do was check if the variable number has changed rather than the ValueObject. I see you've corrected it in this script, but it would be something to point out to the Asker.
"As a side note, only Instance types have the Changed event."
Since this is manipulating the player's gui directly, there is no point in moving this to a server script.
Not that it matters to me. If it's not broken, it doesn't need fixing.