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

I tried to change my button color but it doesnt work.?

Asked by 6 years ago
Edited 6 years ago

Ok basically when i press button the color needs to change.

so what i used was

button.MouseButton1Down:connect(function()
 button.BackgroundColor3 = Color3.new(129, 2, 232)
end)

but that doesnt work it just changes the color to white and breaks the entire button.

0
button is a variable? DeceptiveCaster 3761 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

OOOF, I think I know what you are doing wrong. I didn't see but 3 lines of your script, so it could potentially be because of other things too, but based on your three lines of code, I see one problem: The color. See, when you use color3.new, you have to divide your R, G, and B values by 255, because Color3 is either 0, 1, or a decimal between those two. since you values are more than 1, the computer deems them as 1, and so you color basically turns out as white. So to fix the problem, you either need to divide your RGB values by 255 or use Color3.fromRGB. Color3.fromRGB is like color3.new, except there are no decimals. SO basically this is what you need to do:

button.MouseButton1Down:connect(function()
 button.BackgroundColor3 = Color3.fromRGB(129, 2, 232)
end)

and you are done. fixed.

0
:connect is deprecated use :Connect yHasteeD 1819 — 6y
0
or Color3.new((129/255), (2/255), (232/255)) DeceptiveCaster 3761 — 6y
Ad

Answer this question