How do I change the background color of a gui when a player clicked it?
Depends on how you want it done.
This is the controlled version:
01 | ColorOne = 1 , 0 , 0 |
02 | ColorTwo = 0 , 1 , 0 |
03 | ColorThree = 0 , 0 , 1 |
04 | script.Parent.MouseButton 1 Down:connect( function () |
05 | if script.Parent.BackgroundColor = = ColorOne then |
06 | script.Parent.BackgroundColor = Color 3. new(ColorTwo) |
07 | elseif script.Parent.BackgroundColor = = ColorTwo then |
08 | script.Parent.BackgroundColor = Color 3. new(ColorThree) |
09 | else |
10 | script.Parent.BackgroundColor = Color 3. new(ColorOne) |
11 | end ) |
You could do a more complex one with math.random.
You must put this in a TextButton
This code will change the color of the TextButton when clicked!
01 | ----- |
02 | color = "Black" -- put color you want here |
03 | ----- |
04 |
05 |
06 |
07 | sp = script.Parent |
08 |
09 | function click() |
10 | sp.BackgroundColor 3 = BrickColor.new(color).Color |
11 | end |