Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Disable and stop a script that is in a while true do loop?

Asked by 2 years ago

I have a script that is running "while true do" but I need another script to stop the loop and disable the script, but I cant figure out how to do it, No matter what I try.

This is the script. What would I do in another script to make it stop the script from running, and then disable this script?

ELS = script.Parent

while true do
    wait(0)
    if ELS.lbon.Value == 1 then
        ELS.Lightbar1.FLBR.Transparency = 0
        ELS.Lightbar1.LB1.Transparency = 0
        ELS.Lightbar1.LB2.Transparency = 0
        ELS.Lightbar1.LB3.Transparency = 0
        ELS.Lightbar1.LB4.Transparency = 0
        ELS.Lightbar1.FLBL.Transparency = 0
    elseif ELS.lbon.Value == 2 then
        ELS.Lightbar1.RLBR.Transparency = 1
        ELS.Lightbar1.FLBR.Transparency = 0
        ELS.Lightbar1.LB1.Transparency = 1
        ELS.Lightbar1.LB2.Transparency = 0
        ELS.Lightbar1.LB3.Transparency = 1
        ELS.Lightbar1.LB4.Transparency = 0
        ELS.Lightbar1.FLBL.Transparency = 1
        ELS.Lightbar1.RLBL.Transparency = 0     
        wait(0.2)
        ELS.Lightbar1.RLBR.Transparency = 0
        ELS.Lightbar1.FLBR.Transparency = 1
        ELS.Lightbar1.LB1.Transparency = 0
        ELS.Lightbar1.LB2.Transparency = 1
        ELS.Lightbar1.LB3.Transparency = 0
        ELS.Lightbar1.LB4.Transparency = 1
        ELS.Lightbar1.FLBL.Transparency = 0
        ELS.Lightbar1.RLBL.Transparency = 1
        wait(0.2)
        ELS.Lightbar1.RLBR.Transparency = 1
        ELS.Lightbar1.FLBR.Transparency = 0
        ELS.Lightbar1.LB1.Transparency = 1
        ELS.Lightbar1.LB2.Transparency = 0
        ELS.Lightbar1.LB3.Transparency = 1
        ELS.Lightbar1.LB4.Transparency = 0
        ELS.Lightbar1.FLBL.Transparency = 1
        ELS.Lightbar1.RLBL.Transparency = 0
        wait(0.2)
        ELS.Lightbar1.RLBR.Transparency = 0
        ELS.Lightbar1.FLBR.Transparency = 1
        ELS.Lightbar1.LB1.Transparency = 0
        ELS.Lightbar1.LB2.Transparency = 1
        ELS.Lightbar1.LB3.Transparency = 0
        ELS.Lightbar1.LB4.Transparency = 1
        ELS.Lightbar1.FLBL.Transparency = 0
        ELS.Lightbar1.RLBL.Transparency = 1
        wait(0.2)
    elseif ELS.lbon.Value == 3 then
        ELS.Lightbar1.RLBR.Transparency = 1
        ELS.Lightbar1.FLBR.Transparency = 1
        ELS.Lightbar1.LB1.Transparency = 1
        ELS.Lightbar1.LB2.Transparency = 1
        ELS.Lightbar1.LB3.Transparency = 1
        ELS.Lightbar1.LB4.Transparency = 1
        ELS.Lightbar1.FLBL.Transparency = 1
        ELS.Lightbar1.RLBL.Transparency = 1
        end
    end
0
There's definitely another way of doing this. You should avoid wait(n) for example, wait(1) could wait longer depending on your FPS. MarkedTomato 810 — 2y
0
MarkedTomato got too far you can use wait() but it's just not recommended Xapelize 2658 — 2y
0
MarkedTomato and Xapelize- that is not my problem though. Please contribute to my question CanadianAviatorRBX -5 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

All you need is a return false!

Example While Loop with 'return false'

local number = 5

while true do
    wait(0.1)
    if number > 0 then
        number -= 1
        print("Iteration")
    else
        return false -- What you need!
    end
end

Hope this helped!

0
Still isnt working. Now the script for the lights just isnt working. CanadianAviatorRBX -5 — 2y
0
Could you post your script with the return false? EightBlits 7 — 2y
Ad

Answer this question