Loop not resuming?

Hi forum,
I’m looking to achieve a screensaver that repeats through decals to make a moving image.

I have a script which detects if “screensaver” is true and “debounce” is true when the door is opened debounce is false and 5 seconds after the door is inactive it will make debounce and 20 seconds after that screensaver will be true

-- ScreenSaver script
while screensaver and debounce do
	local x = keyscanner1Screen
	tab = {x.a, x.b, x.c, x.d, x.e, x.f, x.g, x.h, x.i, x.j, x.k, x.l, x.m}
	for i,v in pairs (tab) do
   	 	v.Transparency = 0
   	 	wait (.1) 
   		v.Transparency = 1
	end
end

The script works when I first spawn in however when I open the door and wait 20 seconds the screen simply turns black and the above script doesn’t work. Is there any way to resume the loop?
Feel free to tell me if you need any more info or if I missed anything

The second debounce = false, the while loop will break. Instead of making the booleans conditions in the while argument, change them to if statements (if you want the loop to never break.)

while wait() do
    if screensaver and debounce then
    local x = keyscanner1Screen
    tab = {x.a, x.b, x.c, x.d, x.e, x.f, x.g, x.h, x.i, x.j, x.k, x.l, x.m}
        for i,v in pairs (tab) do
 	        v.Transparency = 0
 	        wait (.1) 
	        v.Transparency = 1
        end
    end
end
2 Likes