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

Weird Error with BackgroundColor3?

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! :)

1 comment

0

Are you sure Fly is a GuiObject and not a function?

1 answer

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.

1 comment

0

oh sry i just made an copy paste error... I got this in my script already.

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