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

How do I make the background color of a Gui change when clicked?

How do I change the background color of a gui when a player clicked it?

2 answers

Depends on how you want it done.

This is the controlled version:

ColorOne = 1, 0, 0
ColorTwo = 0, 1, 0
ColorThree = 0, 0, 1
script.Parent.MouseButton1Down:connect(function()
	if script.Parent.BackgroundColor == ColorOne then
		script.Parent.BackgroundColor = Color3.new(ColorTwo)
	elseif script.Parent.BackgroundColor == ColorTwo then
		script.Parent.BackgroundColor = Color3.new(ColorThree)
	else
		script.Parent.BackgroundColor = Color3.new(ColorOne)
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!

-----
color = "Black" -- put color you want here
-----



sp=script.Parent

function click()
sp.BackgroundColor3 = BrickColor.new(color).Color
end

More info on TextButtons click here

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