So, I've been trying to figure out how to properly rebuild my ELS script, but when I brought it up to someone else I just got scrutinized for how old and Sh*tty it was, any idea's and recommendations would be fantastic. Here is some of the code:
ELS = script.Parent while true do wait(0) if script.Parent.Lon.value == true and script.Parent.TAPattern.value == 4 then ELS.RTA1.BrickColor = BrickColor.new ("Medium blue") ELS.RTA2.BrickColor = BrickColor.new ("Lily white") ELS.RTA3.BrickColor = BrickColor.new ("Medium blue") ELS.RTA4.BrickColor = BrickColor.new ("Lily white") ELS.RTA5.BrickColor = BrickColor.new ("Medium blue") ELS.RTA6.BrickColor = BrickColor.new ("Lily white") ELS.RTA7.BrickColor = BrickColor.new ("Medium blue") ELS.RTA8.BrickColor = BrickColor.new ("Lily white") ELS.RTA9.BrickColor = BrickColor.new ("Medium blue") ELS.RTA10.BrickColor = BrickColor.new ("Lily white") ELS.RTA1.Transparency = 0 ELS.RTA2.Transparency = 1 ELS.RTA3.Transparency = 1 ELS.RTA4.Transparency = 1 ELS.RTA5.Transparency = 1 ELS.RTA6.Transparency = 1 ELS.RTA7.Transparency = 1 ELS.RTA8.Transparency = 1 ELS.RTA9.Transparency = 1 ELS.RTA10.Transparency = 1 wait(0.01) ELS.RTA1.Transparency = 1 ELS.RTA2.Transparency = 0 ELS.RTA3.Transparency = 1 ELS.RTA4.Transparency = 1 ELS.RTA5.Transparency = 1 ELS.RTA6.Transparency = 1 ELS.RTA7.Transparency = 1 ELS.RTA8.Transparency = 1 ELS.RTA9.Transparency = 1 ELS.RTA10.Transparency = 1 wait(0.01) ELS.RTA1.Transparency = 1 ELS.RTA2.Transparency = 1 ELS.RTA3.Transparency = 0 ELS.RTA4.Transparency = 1 ELS.RTA5.Transparency = 1 ELS.RTA6.Transparency = 1 ELS.RTA7.Transparency = 1 ELS.RTA8.Transparency = 1 ELS.RTA9.Transparency = 1 ELS.RTA10.Transparency = 1
You can see how "Sh*tty" it is. RTA = Rear Traffic Advisor (I have the TA on the lightbar and the one in the rear window)
This is just how I personally would do it.
local ELS = script.Parent; local frames = { {B1 = 1; R1 = 0;}; {B1 = 0; R1 = 1;}; }; local currFrame = 0; while wait() do if script.Parent.Lon.Value == true and script.Parent.LPattern.Value == 0 then for Light, Value in pairs(frames) do local lightObj = ELS:FindFirstChild(Light); lightObj.Transparency = Value; --lightObj:FindFirstChild("PointLight").Enabled = (Value == 0); end; currFrame = currFrame + 1; if currFrame > #frames then currFrame = 1; end; else currFrame = 1; end; end;
Again, this is just how I would do it. I have not made an ELS system before but have wanted to. This is the quick and dirty way that I would do it. The pretty way I would do it would be making a ModuleScript that allows you to add and remove frames.