So I just tried to make a activate/deactivate button with changing their color (white if deactivated, red if activated). My code:
01 | local Button = Instance.new( "TextButton" ) |
02 | local ButtonActivated = false |
03 | local ActivatedColor = Color 3. fromRGB( 170 , 0 , 0 ) |
04 | local DefaultColor = Color 3. fromRGB( 255 , 255 , 255 ) |
05 |
06 | Button.MouseButton 1 Click:Connect( function () |
07 | if buttonActivated = = false then |
08 | Button.BackgroundColor 3 = ActivatedColor |
09 | else |
10 | Button.BackgroundColor 3 = DefaultColor |
11 | end |
12 | if ButtonActivated = = false then |
13 | -- Activating... |
14 | else |
15 | -- Deactivating... |
16 | end |
17 | end ) |
And it gives the following error:
Players.Hello1502HD.PlayerGui.Script:8: attempt to index function with 'BackgroundColor3'
I can't understand that.
Thx for reading and maybe helping! :)
01 | local Button = Instance.new( "TextButton" ) |
02 | local ButtonActivated = false |
03 | local ActivatedColor = #PUTCOLORSHERE |
04 | local DefaultColor = Button.BackgroundColor 3 |
05 |
06 | Button.MouseButton 1 Click:Connect( function () |
07 | if buttonActivated = = false then |
08 | Button.BackgroundColor 3 = Color 3. new(ActivatedColor) |
09 | buttonActivated = true |
10 | elseif buttonActivated = = true then |
11 | Button.BackgroundColor 3 = Color 3. new(DefaultColor) |
12 | buttonActivated = false |
13 | end |
14 | end ) |
the thing is you're trying to relate nothing, and an object to the color you want to put, and not colors
example, you want to have some coffee, but you dont even get a cup, instead, you have a bottle.