Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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

Log in to vote
0
Answered by
TGazza 1336 Moderation Voter
3 years ago

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)
Ad

Answer this question