How do I make the Background change with varibles and color3 values?

local R = script.Parent.Parent.Red.Number.RedColor
local G = script.Parent.Parent.Green.Number.GreenColor 
local B = script.Parent.Parent.Blue.Number.BlueColor 
local color = script.Parent.Color1 

while true do
	color = Color3.new(R,G,B)
	script.Parent.BackgroundColor3 = color
	print(color)
	wait(0.01)
end

So am I right that you want to change the script.Parent.BackgroundColor3? Because if yes, then you have to switch color = script.Parent.BackgroundColor3 to script.Parent.BackgroundColor3 = color

Thanks for the fix but it did not fully fix it

Well what is your problem, what do you want to fully achieve?

I want 3 number values, red, green, blue, and go into a color3 value, which determan a background for a gui frame

local R = 255
local G = 255
local B = 255
local color = script.Parent.Color1 --What is that btw???

while true do
	color = Color3.new(R,G,B)
	script.Parent.BackgroundColor3 = color
	print(color)
	wait(0.01)
end

Since Color3 takes 3 number inputs, try it with that. What exatly is script.Parent.Color1?

May I ask what you are changing the values with?

local ColorValues = Script.Parent.Parent.Colors -- You should structure your stuff differently
local R = ColorValues.Red 
local G = ColorValues.Green
local B = ColorValues.Blue

while wait() do
  -- Make sure you do .Value to get the value
  local NewColor = Color3.fromRGB(R.Value, G.Value, B.Value)
  print(NewColor)
  script.Parent.BackgroundColor3 = NewColor
end
local ColorValues = Script.Parent.Parent.Colors
local R = ColorValues.Red
local G = ColorValues.Green
local B = ColorValues.Blue

-- Or you could loop through all of the Values and update the background when one changes
for _, Color in ColorValues:GetChildren() do
  if not Color:IsA("Value") then continue end
  Color.Changed:Connect(function()
    local NewColor = Color3.fromRGB(R.Value, G.Value, B.Value)
    script.Parent.BackgroundColor3 = NewColor
  end)
end
-- You could also do something like this to make things smaller (i wouldn't)
local R, G, B = unpack(ColorValues:GetChildren())
print(R.Value, G.Value, B.Value)

the problem was you were never getting the values from your colors (NumberValue.Value)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.