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

How do I change the BrickColor onClicked? :D

Asked by 10 years ago

Im making a button but I want the color to change from green to red on clicked :D Please Help.

script.Parent.ClickDetector.MouseClick:connect(function()
    script.Parent.BrickColor    =   BrickColor.new("Really red")
end)

1 answer

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Are you trying to make it alternate? If so, you need a debounce.

green = true
script.Parent.ClickDetector.MouseClick:connect(function()
    if green == true then
        green = false
        script.Parent.BrickColor = BrickColor.new("Really red")
    else
        green = true
        script.Parent.BrickColor = BrickColor.new("Bright green")
    end
end)
Ad

Answer this question