So I just tried to make a activate/deactivate button with changing their color (white if deactivated, red if activated). My code:
local Button = Instance.new("TextButton") local ButtonActivated = false local ActivatedColor = Color3.fromRGB(170, 0, 0) local DefaultColor = Color3.fromRGB(255, 255, 255) Button.MouseButton1Click:Connect(function() if buttonActivated == false then Button.BackgroundColor3 = ActivatedColor else Button.BackgroundColor3 = DefaultColor end if ButtonActivated == false then -- Activating... else -- Deactivating... end 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! :)
local Button = Instance.new("TextButton") local ButtonActivated = false local ActivatedColor = #PUTCOLORSHERE local DefaultColor = Button.BackgroundColor3 Button.MouseButton1Click:Connect(function() if buttonActivated == false then Button.BackgroundColor3 = Color3.new(ActivatedColor) buttonActivated = true elseif buttonActivated == true then Button.BackgroundColor3 = Color3.new(DefaultColor) buttonActivated = false end 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.