Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

button is a variable?

1 answer

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.

2 comments

0

:connect is deprecated use :Connect

0

or Color3.new((129/255), (2/255), (232/255))

This discussion is preserved as it was. New answers, comments, and votes are closed.