Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

3 comments

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.

0

MarkedTomato got too far you can use wait() but it's just not recommended

0

MarkedTomato and Xapelize- that is not my problem though. Please contribute to my question

1 answer

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!

2 comments

0

Still isnt working. Now the script for the lights just isnt working.

0

Could you post your script with the return false?

This discussion is preserved as it was. New answers, comments, and votes are closed.