Hello! I have an issue. I am trying to sync my railroad depot control signals with a switch, but it seems as if there is no way to do that. I'm confused a bit.
function onClicked() if script.Parent.Parent.Parent.IsOn.Value == false then script.Parent.Parent.Parent.IsOn.Value = true script.Parent.Parent.Switch2.Transparency = 1 script.Parent.Parent.Switch2a.Transparency = 1 script.Parent.Parent.Switch2b.Transparency = 1 script.Parent.Parent.Switch1.Transparency = 0 script.Parent.Parent.Switch1a.Transparency = 0 script.Parent.Parent.Switch1b.Transparency = 0 elseif script.Parent.Parent.Parent.IsOn.Value == true then script.Parent.Parent.Parent.IsOn.Value = false script.Parent.Parent.Switch2.Transparency = 0 script.Parent.Parent.Switch2a.Transparency = 0 script.Parent.Parent.Switch2b.Transparency = 0 script.Parent.Parent.Switch1.Transparency = 1 script.Parent.Parent.Switch1a.Transparency = 1 script.Parent.Parent.Switch1b.Transparency = 1 end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Thats for the outside source which controls the IsOn value for the ControlBox model which activates the lights and does its stuff. Here is the script for the track switch (independent of the outside source)
Here is the script for the track switch itself:
local Open = true local Trans = {[true] = 0, [false] = 0.8} wait(0.1) function SetState(state) for _, p in pairs(script.Parent:GetChildren()) do if p.Name == "Open" then p.CanCollide = state p.Transparency = Trans[state] elseif p.Name == "Close" then p.CanCollide = not state p.Transparency = Trans[not state] end end Open = state end script.Parent.OpenBlock.Touched:connect(function(p) SetState(true) end) script.Parent.CloseBlock.Touched:connect(function(p) SetState(false) end) script.Parent.Switch.Click.MouseClick:connect(function() SetState(not Open) end) SetState(true)
Any help is appreciated. Thanks!