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

Is it possible to connect a button to a brick?

I am making a game that has a button you click, in a part called "button" and it would change the color to the brick called "rm1" to be bright red. If the button is clicked again "rm1" changes back to the original color of bright green.

I would really like the script for this, if there is one.

Thanks!

4 comments

0

What have you tried so far?

0

So far I got it to turn red, but I cannot get it back to green. When the "button" brick changes colors I want the "rm1" brick to change to the same color this is the code I used function onClicked(playerWhoClicked) script.Parent.BrickColor = BrickColor.Red() end script.Parent.ClickDetector.MouseClick:connect(onClicked)

0

Mainly the one roblox exampled

0

This is an easy script to make. However, scripting helpers is not a request site. You have to have some kind of script that you tried and failed with. You cannot just simply ask for a script.

1 answer

Found the script

Button1 = script.Parent rm1 = script.Parent.Parent local debounce = true local function onClicked() if debounce then Button1.BrickColor = BrickColor.new("Bright red") rm1.BrickColor = BrickColor.new("Bright red")

elseif debounce == false then Button1.BrickColor = BrickColor.new("Bright green") rm1.BrickColor = BrickColor.new("Bright green") end end script.Parent.ClickDetector.MouseClick:connect(onClicked)

local function onClicked() if debounce then debounce = false elseif debounce == false then debounce = true end end script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment

0

cry everytime no codeblock

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