|
| 11 Jun 2017 11:05 PM |
open=true
script.Parent.MouseClick:connect(function() if open==true then open=false while true do script.Parent.Parent.Parent.Light_Red.Material =("Neon") script.Parent.Parent.Parent.Light_Red.PointLight.Enabled=true wait(0.2) script.Parent.Parent.Parent.Light_Red.PointLight.Enabled=false script.Parent.Parent.Parent.Light_Red.Material =("SmoothPlastic") wait(0.2) end --anything below this wont work >:( while true do script.Parent.Parent.Parent.Light_Blue.Material =("SmoothPlastic") wait(0.2) script.Parent.Parent.Parent.Light_Blue.Material =("Neon") script.Parent.Parent.Parent.Light_Blue.PointLight.Enabled=true wait(0.2) script.Parent.Parent.Parent.Light_Blue.PointLight.Enabled=false end else open=true script.Parent.Parent.Parent.Light_Blue.Material=("SmoothPlastic") script.Parent.Parent.Parent.Light_Blue.SpotLight.Enabled=false script.Parent.Parent.Parent.Light_Red.Material=("SmoothPlastic") script.Parent.Parent.Parent.Light_Red.SpotLight.Enabled=false end end) |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2017 11:10 PM |
| The reason why the code below your while loop doesn't work is because your first while loop is still going on and on. It hasn't completed its loop because it'll always be true. So if I am thinking right, you made an infinite loop which means it won't go to the next loop. |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Jun 2017 02:36 AM |
Basically anything below the first "while true do" won't run because the first one is still looping, try doing :
for i = 1, (number of times you want it to loop) do script.Parent.Parent.Parent.Light_Red.Material =("Neon") script.Parent.Parent.Parent.Light_Red.PointLight.Enabled=true wait(0.2) script.Parent.Parent.Parent.Light_Red.PointLight.Enabled=false script.Parent.Parent.Parent.Light_Red.Material =("SmoothPlastic") wait(0.2) end |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2017 08:43 PM |
I'm not necessarily sure how you want this code to execute but what you can do is create the MouseClick event to control the boolean open, and have an if statement in a while loop to check if the boolean is true or false. I also combined the two while loops you had and put it into one and assumed that you may have wanted to have certain things done if open was true, and other things done if open was false.
open=true part = script.Parent
script.Parent.MouseClick:connect(function() if open then open = not open end end)
while true do if open then script.Parent.Parent.Parent.Light_Red.Material =("Neon") script.Parent.Parent.Parent.Light_Red.PointLight.Enabled=true script.Parent.Parent.Parent.Light_Blue.Material =("SmoothPlastic")
wait(0.2)
script.Parent.Parent.Parent.Light_Blue.Material =("Neon") script.Parent.Parent.Parent.Light_Blue.PointLight.Enabled=true script.Parent.Parent.Parent.Light_Red.PointLight.Enabled=false script.Parent.Parent.Parent.Light_Red.Material =("SmoothPlastic") wait(0.2)
script.Parent.Parent.Parent.Light_Blue.PointLight.Enabled=false script.Parent.Parent.Parent.Light_Blue.Material =("SmoothPlastic") wait(0.2) script.Parent.Parent.Parent.Light_Blue.Material =("Neon") script.Parent.Parent.Parent.Light_Blue.PointLight.Enabled=true wait(0.2) script.Parent.Parent.Parent.Light_Blue.PointLight.Enabled=false else script.Parent.Parent.Parent.Light_Blue.Material=("SmoothPlastic") script.Parent.Parent.Parent.Light_Blue.SpotLight.Enabled=false script.Parent.Parent.Parent.Light_Red.Material=("SmoothPlastic") script.Parent.Parent.Parent.Light_Red.SpotLight.Enabled=false end end |
|
|
| Report Abuse |
|
|