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

This doesn't run all together...?

Asked by 8 years ago

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

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
8 years ago

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)
Ad

Answer this question