Hey guys i have a script which prints turned on how would i make it to where it will print turned off when i click it again here is the code i can't figure it out.
(When i click it i want it to print clicked on and when i click it a second time i want it to say clicked off)
button = script.Parent cl = Instance.new("ClickDetector",button) clicked = false button.ClickDetector.MouseClick:connect(function() if clicked == false then clicked = true print("Clicked on") print("Clciked off") --having trouble here clicked = false end end)
You didn't add anything to check if "clicked" was off.
local button = script.Parent local cl = Instance.new("ClickDetector", button) local clicked = false cl.MouseClick:connect(function() if not clicked then clicked = true print"Clicked on." elseif clicked then clicked = false print"Clicked off." end end)