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

Help! Railroad Crossing script not working?

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

1 comment

0

Also the this code is all in different scripts, not LOCAL.

1 answer

✓ Accepted answer

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.

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