I'm trying to make an on/off object with only one button. I've made a little test which does the following: - The first time you click it, it changes the brickcolor of a part called ''on''. Then it changes the color of the button itself.
I've made this little test to understand how to script an on/off button. But It won't work.
Here's my script.
if script.Parent.Parent.testbutton.BrickColor = Color3(255, 0, 0) then script.Parent.ClickDetector.MouseClick:Connect(function() script.Parent.Parent.on.BrickColor = Color3.new(0, 255, 255) script.Parent.Parent.testbutton.BrickColor = Color3.new(0, 255, 0) elseif script.Parent.Parent.testbutton.BrickColor = Color3(0, 255, 0) then script.Parent.Parent.off.BrickColor = Color3.new(0, 255, 255) end end) end
On = Part 1 Off = Part 2
I would really like some help! Thank you in advance.
I formated your code a bit. But I'm not sure it will run. Try it
if script.Parent.Parent.testbutton.BrickColor == Color3(255, 0, 0) then script.Parent.ClickDetector.MouseClick:Connect(function() script.Parent.Parent.on.BrickColor = Color3.new(0, 255, 255) script.Parent.Parent.testbutton.BrickColor = Color3.new(0, 255, 0) end) elseif script.Parent.Parent.testbutton.BrickColor == Color3(0, 255, 0) then script.Parent.Parent.off.BrickColor = Color3.new(0, 255, 255) end