I am trying to create a railway block signal, and the following script isn’t working. There’s a seperate script that handles the sensor, which works fine. This script is meant to allow the signal to be easily modified by only needing one value to be changed (The end of the top variable)
I don’t know why, but this script doesn’t work, no errors, just doesn’t change the state, the signal never changes from red
local NextSignal = script.Parent.Parent.Signal_A003
local Sensor = script.Parent.Sensor
local debounce = false
local State = script.Parent.State.Value
local Code = script.Parent.Parent.Name
local Click = script.Parent.Click
local L1 = script.Parent.L1
local L2 = script.Parent.L2
--End of variables
--
--Main Code
while true do
wait()
if NextSignal.State.Value == "Red" then
wait(5)--Time to wait until signal state changes, this should allow the train infront to clear the block before allowing another train through
L1.BrickColor = BrickColor.new("Neon orange")
L2.BrickColor = BrickColor.new("Neon orange")
State = "Orange"
--This changes the state of the signal and the lights
elseif NextSignal.State.Value == "Orange" then
wait(5)--Time to wait until signal state changes, this should allow the train infront to clear the block before allowing another train through
L1.BrickColor = BrickColor.new("Lime green")
L2.BrickColor = BrickColor.new("Really black")
State = "Green"
--This changes the state of the signal and the lights
elseif NextSignal.State.Value == "Green" then
--Nothing happens here as if the signal infront is green, nothing should be done
end
end
I would appreciate any help I can get, feel free to ask questions!