I want to make a button that changes color once I click it and reverts back to normal once I click it again. I made a script, it does not work. Here is the script.
function leftClick() script.Parent.TextColor3 = Color3.new(0, 255, 0) end function leftClick() script.Parent.TextColor3 = Color3.FromRGB(255,0,0) end script.Parent.MouseButton1Click:Connect(leftClick)
local on = false -- Set it to false if it's off when the game starts (on is true) local function leftClick() if not on then script.Parent.TextColor3 = Color3.fromRGB(255, 0, 0) on = true else script.Parent.TextColor3 = Color3.fromRGB(0, 255, 0) on = false end end script.Parent.MouseButton1Click:Connect(leftClick)
**Is the button a GUI or a part of the workspace? **
*You need to use a click detector. Put one into you object. *
ClickDetector.MouseClick:Connect(function() --Write code here to change colors. end)