Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

2 answers

Log in to vote
0
Answered by 10 years ago

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.

Ad
Log in to vote
0
Answered by
Dominical 215 Moderation Voter
10 years ago

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

Answer this question