local on = false script.Parent.MouseButton1Down:connect(onClicked) if not on then on = true elseif on then on = false end end) while on do game.Workspace.Test4.Light1.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light2.BrickColor = BrickColor.new("Really red") game.Workspace.Test4.Light3.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light4.BrickColor = BrickColor.new("Really red") game.Workspace.Test4.Light5.BrickColor = BrickColor.new("Really red") game.Workspace.Test4.Light6.BrickColor = BrickColor.new("Really red") wait(1) game.Workspace.Test4.Light1.BrickColor = BrickColor.new("Really red") game.Workspace.Test4.Light2.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light3.BrickColor = BrickColor.new("Really red") game.Workspace.Test4.Light4.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light5.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light6.BrickColor = BrickColor.new("Medium stone grey") wait(1) game.Workspace.Test4.Light1.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light2.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light3.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light4.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light5.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light6.BrickColor = BrickColor.new("Medium stone grey") wait(1) end while not on do game.Workspace.Test4.Light1.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light2.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light3.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light4.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light5.BrickColor = BrickColor.new("Medium stone grey") game.Workspace.Test4.Light6.BrickColor = BrickColor.new("Medium stone grey") wait() end
To start off, you have multiple while true do
loops. When you run one of those loops, it'll keep running and never get past that loop unless you would use coroutine. Well, I have my way that may not be the most efficient, but always gets the job done. I'd make 3 scripts in total. One that would toggle the on/off, one that would be looping the on, and the last looping the off. Here's how it would look:
Toggle Script:
local on = false OnScript = script.On -- Should be disabled by default OffScript = script.Off -- Should be disabled by default script.Parent.MouseButton1Down:connect(function() -- If this is a ClickDector, make it MouseClick if on == false then on = true OffScript.Disabled = true OnScript.Disabled = false else on = false OnScript.Disabled = true OffScript.Disabled = false end end)
On Script: (Should be disabled by default)
Light1 = game.Workspace.Test4.Light1 Light2 = game.Workspace.Test4.Light2 Light3 = game.Workspace.Test4.Light3 Light4 = game.Workspace.Test4.Light4 Light5 = game.Workspace.Test4.Light5 Light6 = game.Workspace.Test4.Light6 while true do Light1.BrickColor = BrickColor.new("Medium stone grey") Light2.BrickColor = BrickColor.new("Really red") Light3.BrickColor = BrickColor.new("Medium stone grey") Light4.BrickColor = BrickColor.new("Really red") Light5.BrickColor = BrickColor.new("Really red") Light6.BrickColor = BrickColor.new("Really red") wait(1) Light1.BrickColor = BrickColor.new("Really red") Light2.BrickColor = BrickColor.new("Medium stone grey") Light3.BrickColor = BrickColor.new("Really red") Light4.BrickColor = BrickColor.new("Medium stone grey") Light5.BrickColor = BrickColor.new("Medium stone grey") Light6.BrickColor = BrickColor.new("Medium stone grey") wait(1) Light1.BrickColor = BrickColor.new("Medium stone grey") Light2.BrickColor = BrickColor.new("Medium stone grey") Light3.BrickColor = BrickColor.new("Medium stone grey") Light4.BrickColor = BrickColor.new("Medium stone grey") Light5.BrickColor = BrickColor.new("Medium stone grey") Light6.BrickColor = BrickColor.new("Medium stone grey") wait(1) end
Off script: (Should be disabled as default)
Light1 = game.Workspace.Test4.Light1 Light2 = game.Workspace.Test4.Light2 Light3 = game.Workspace.Test4.Light3 Light4 = game.Workspace.Test4.Light4 Light5 = game.Workspace.Test4.Light5 Light6 = game.Workspace.Test4.Light6 while wait() do Light1.BrickColor = BrickColor.new("Medium stone grey") Light2.BrickColor = BrickColor.new("Medium stone grey") Light3.BrickColor = BrickColor.new("Medium stone grey") Light4.BrickColor = BrickColor.new("Medium stone grey") Light5.BrickColor = BrickColor.new("Medium stone grey") Light6.BrickColor = BrickColor.new("Medium stone grey") end