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

My script has failed with no errors, even though all conditions are met?

I have a script to disable the controls to a control board if a control box breaks. However, the box isn't broken, yet the levers and controls don't operate. Code is below. It still plays the sound, but everything about changing it doesn't work.

function onClicked()
	script.Parent.switch:Play()
	 if game.Workspace.Controlbreak.Broken == false then
	  if game.Workspace.Variables.Reactorvalve.Value == false then
		Game.Workspace.Variables.Reactorvalve.Value = true
	  elseif game.Workspace.Variables.Reactorvalve.Value == true then
		Game.Workspace.Variables.Reactorvalve.Value = false
	  end
	end	
end 

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

✓ Accepted answer

hmm could it be as simple as a missing .Value from your first if statement?

function onClicked()
    script.Parent.switch:Play()
   --  change this from \/\/\/\/ 
-- if game.Workspace.Controlbreak.Broken == false then <<
 if game.Workspace.Controlbreak.Broken.Value == false then -- << to this ?
      if game.Workspace.Variables.Reactorvalve.Value == false then
        Game.Workspace.Variables.Reactorvalve.Value = true
      elseif game.Workspace.Variables.Reactorvalve.Value == true then
        Game.Workspace.Variables.Reactorvalve.Value = false
      end
    end 
end 

script.Parent.ClickDetector.MouseClick:connect(onClicked)

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