Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My color3 isn't working and won't change color any help?

Asked by 6 years ago

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)

0
:( nooooooooooooooooooooo my biggest enemy, NO CODE BLOCKS! hiimgoodpack 2009 — 6y
0
Put this in a code block please. T0XN 276 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

replace

Color3.new

by

Color3.fromRGB
Ad
Log in to vote
0
Answered by
iloveu6 20
6 years ago

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!

Answer this question