so I'm making a game where you can toggle on/off name tags, I made a script to change the on/off button color when you press it, it works fine but when you press it once and press it again, the color I want won't show up. Heres the script:
local On = SettingButton.SettingBackground.NameTags.OnOff lol = true SettingButton.SettingBackground.NameTags.OnOff.MouseButton1Click:connect(function() if lol == true then lol = false On.BackgroundColor3 = Color3.new(255,0,0) On.Text = ('Off') else if lol == false then lol = true On.BackgroundColor3 = Color3.new(26,163,10) On.Text = ('On') end end end)
Late on this response a bit, but the problem is the Color3. If you're using Color3, the value is from 0-1, not 0-255, and to fix this you must divide the numbers by putting /255 after each value. Try this:
local On = SettingButton.SettingBackground.NameTags.OnOff lol = true SettingButton.SettingBackground.NameTags.OnOff.MouseButton1Click:connect(function() if lol == true then lol = false On.BackgroundColor3 = Color3.new(255/255, 0/255, 0/255) On.Text = ('Off') else if lol == false then lol = true On.BackgroundColor3 = Color3.new(26/255,163/255, 10/255) On.Text = ('On') end end end)
Or, just use .fromRGB like F4ULT said. Please fix any of my mistakes!