Basically I made this script for my train crossing. Its like one of those electric boxes that the workers use to control it. The GUI giver works but the Scripts in the GUI don't work.
I will start you off with some code here. I got 4 buttons, I'm thinking I simply forgot something very easy. Help would be appreciated.
This is the one which turns the crossing signal on
script.Parent.MouseButton1Down:connect(function() game.Workspace.crossing1.state = true end)
This turns the crossing signal off
script.Parent.MouseButton1Down:connect(function() game.Workspace.crossing1.state = false end)
I also have 2 other buttons for disabling and enabling the crossing here is the first one. This enables the crossing.
script.Parent.MouseButton1Down:connect(function() game.Workspace.crossing1.state = false game.Workspace.crossing1.Script.Disabled = false end)
And this one disables the crossing.
script.Parent.MouseButton1Down:connect(function() game.Workspace.crossing1.state = false game.Workspace.crossing1.Script.Disabled = true end)
Thanks for the help :)
Canonically, names for objects should be PascalCase
, so it's better practice to use Crossing1
over crossing1
(of course the actual name of the object must match this).
Don't enable and disable scripts to produce functionality. That's an awful, unclear, incorrect way to do it.
There is no property called state
of anything. If you're using a BoolValue, you have to write to its Value
** property.
The output would have warned you of the above error. Use the output. You'll make a bad programmer if your answer to debugging is shrugging instead of trying to figure things out.