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

This doesn't run all together...?

I have 3 "Sounder"s in workspace, only 1 of them works in the following functions :

(look for green text to explain what is happening)

Main Script:

local check = game.Workspace:GetChildren()
function click()
	for i,v in pairs (check) do
	      if v.Name == "Sounders" then 
			game.Workspace.Panel.Status.Value = 1
			v.Sound.Sound:Play()        ** -- Only 1 sounder players music here, when 3 should**
			game.Workspace.Panel.LightSync.Value = true
			p.Reason.Text = "Alarm : Pull Station"
			p.Silence.Text = "** SILENCE ALARM **"
			p2.ACK.ClickDetector.MaxActivationDistance = 32
			p2.SILENCE.ClickDetector.MaxActivationDistance = 32
	end
end

function check1()
	if game.Workspace.Panel.LightSync.Value == true then
		for i,v in pairs(check) do
			if v.Name == "Sounder" then
			repeat
				wait(0.4)
				v.Sound.PointLight.Enabled = true ** -- Only 1 sounder flashes the lights, when 3 should**
				wait(0.4)
				v.Sound.PointLight.Enabled = false
				until game.Workspace.Panel.Status.Value == 0
			end
		end
	end
end
game.Workspace.Panel.LightSync.Changed:connect(check1)

1 answer

Repeat until loop on line 24 never resolves, thus only the first light flickers. You should use spawn(function() end ) to make the flicker effect run on a separate thread.

Read more about that here.

function check1()
    if game.Workspace.Panel.LightSync.Value == true then
        for i,v in pairs(check) do
            if v.Name == "Sounder" then
	spawn( function()
            repeat
                wait(0.4)
                v.Sound.PointLight.Enabled = true ** -- Only 1 sounder flashes the lights, when 3 should**
                wait(0.4)
                v.Sound.PointLight.Enabled = false
                until game.Workspace.Panel.Status.Value == 0
	end)
            end
        end
    end
end
game.Workspace.Panel.LightSync.Changed:connect(check1)

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