Hello. I am currently working on a GUI project. My issue is, when I click the button to the "Off" position, the BackgroundColor3 does not change to 161, 161, 161.
Here is the code:
local Button = script.Parent
script.Parent.MouseButton1Click:connect(function()
if script.On.Value == true then
Button:TweenPosition(UDim2.new(0.5, 0, 0, 0), "Out", "Quad", 1)
wait(0.5)
Button.BackgroundColor3 = Color3.new(161, 161, 161)
Button.Text = "Off"
script.On.Value = false
elseif script.On.Value == false then
Button:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quad", 1)
wait(0.5)
Button.BackgroundColor3 = Color3.new(0, 255, 0)
Button.Text = "On"
script.On.Value = true
end
end)
This Script is directly inside of a TextButton. The Value is a BoolValue directly inside of the Script.
This is a Server Script (In other words, Script)
What happens is when I click it to turn Off the BackgroundColor3 is changed to 30090, 30090, 30090 instead of 161, 161, 161.
I'm not sure if I am missing something in my script, or if Color3.new is glitched somehow. It turns 0, 255, 0 (Lime green) when turned On every time.
Thanks for your help guys! I appreciate it!

4 comments
Color3.New(1, 1, 1) is pure white. The numbers are max of one, min of zero. Some people make a color function that divides all values by 255. Color3.new(161/255, 161/255, 161/255) is what you really need for line 6.
I'll try it, but it changes the color to 0, 255, 0 when it is told to.
Well it worked, thanks for your help!
Yep, that threw my head for a few spins too before someone told me that one day. :)