So I recently wrote this script for a traffic light, r1 is the red light for 1 of the signals, and r2 is the second direction signal etc. Is there anyway I can make this script more efficient and less big?
r1 = script.Parent.R1
y1 = script.Parent.Y1
g1 = script.Parent.G1
r2 = script.Parent.R2
y2 = script.Parent.Y2
g2 = script.Parent.G2
r3 = script.Parent.R3
y3 = script.Parent.Y3
g3 = script.Parent.G3
r4 = script.Parent.R4
y4 = script.Parent.Y4
g4 = script.Parent.G4
s1 = script.Parent.S1
while true do
r1.Material = "Neon"
y1.Material = "SmoothPlastic"
g1.Material = "SmoothPlastic"
r2.Material = "SmoothPlastic"
y2.Material = "SmoothPlastic"
g2.Material = "Neon"
r3.Material = "SmoothPlastic"
y3.Material = "SmoothPlastic"
g3.Material = "Neon"
r4.Material = "Neon"
y4.Material = "SmoothPlastic"
g4.Material = "SmoothPlastic"
wait(2)
r1.Material = "SmoothPlastic"
y1.Material = "Neon"
g1.Material = "SmoothPlastic"
r2.Material = "SmoothPlastic"
y2.Material = "Neon"
g2.Material = "SmoothPlastic"
r3.Material = "SmoothPlastic"
y3.Material = "Neon"
g3.Material = "SmoothPlastic"
r4.Material = "SmoothPlastic"
y4.Material = "Neon"
g4.Material = "SmoothPlastic"
wait(2)
r1.Material = "SmoothPlastic"
y1.Material = "SmoothPlastic"
g1.Material = "Neon"
r2.Material = "Neon"
y2.Material = "SmoothPlastic"
g2.Material = "SmoothPlastic"
r3.Material = "Neon"
y3.Material = "SmoothPlastic"
g3.Material = "SmoothPlastic"
r4.Material = "SmoothPlastic"
y4.Material = "SmoothPlastic"
g4.Material = "Neon"
wait(2)
end