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 4 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.

01function onClicked()
02    script.Parent.switch:Play()
03     if game.Workspace.Controlbreak.Broken == false then
04      if game.Workspace.Variables.Reactorvalve.Value == false then
05        Game.Workspace.Variables.Reactorvalve.Value = true
06      elseif game.Workspace.Variables.Reactorvalve.Value == true then
07        Game.Workspace.Variables.Reactorvalve.Value = false
08      end
09    end
10end
11 
12script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

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

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

01function onClicked()
02    script.Parent.switch:Play()
03   --  change this from \/\/\/\/
04-- if game.Workspace.Controlbreak.Broken == false then <<
05 if game.Workspace.Controlbreak.Broken.Value == false then -- << to this ?
06      if game.Workspace.Variables.Reactorvalve.Value == false then
07        Game.Workspace.Variables.Reactorvalve.Value = true
08      elseif game.Workspace.Variables.Reactorvalve.Value == true then
09        Game.Workspace.Variables.Reactorvalve.Value = false
10      end
11    end
12end
13 
14script.Parent.ClickDetector.MouseClick:connect(onClicked)
Ad

Answer this question