I don't know how, but I forgot how this works. I have two scripts. One is for one part as the turn on/off button and the other for the other buttons' functions. Well, for this script, I want to click the button, or Switch, and turn on/off, or Enable/Disable, the script which is called Main. I don't know if that is possible. And if it is, then what did I do wrong here. The on/off button works, but it didn't enable or disable the script. Thank you for helping me!
Switch = script.Parent.Parent.Switch switchOn = false local onoff = game.Workspace.RemoteControl.Pad.Main onoff.Disabled = false function onClicked() if not switchOn then switchOn = true Switch.CFrame = Switch.CFrame+Vector3.new(0,-0.09,0) Switch.BrickColor = BrickColor.new("Shamrock") onoff.Disabled = true -- Enabling the script elseif switchOn then switchOn = false Switch.CFrame = Switch.CFrame+Vector3.new(0,0.09,0) Switch.BrickColor = BrickColor.new("Bright red") onoff.Disabled = false -- Disabling the script end end script.Parent.Parent.Switch.ClickDetector.MouseClick:connect(onClicked)
Try this script:
Switch = script.Parent.Parent.Switch switchOn = false local onoff = game.Workspace.RemoteControl.Pad.Main onoff.Disabled = false script.Parent.Parent.Switch.ClickDetector.MouseClick:Connect(function() if switchOn == true then switchOn = false Switch.CFrame = Switch.CFrame+Vector3.new(0,0.09,0) Switch.BrickColor = BrickColor.new("Bright red") onoff.Disabled = false -- Disabling the script. else switchOn = true Switch.CFrame = Switch.CFrame+Vector3.new(0,-0.09,0) Switch.BrickColor = BrickColor.new("Shamrock") onoff.Disabled = true -- Enabling the script end end end)