Basically the title, I have this script and alot of light models and I want them to flicker together but I can’t get them to do that even with coroutine, any ideas?
local Detector = script.Parent
local debounce = false
local function PersonalLightFlickerOffFunc(LightPart)
repeat
LightPart.Material = "Metal"
LightPart.PointLight.Enabled = false
LightPart.SpotLight.Enabled = false
task.wait(0.1)
LightPart.Material = "Neon"
LightPart.PointLight.Enabled = true
LightPart.SpotLight.Enabled = true
task.wait(0.3)
until
game.SoundService.light_flicker_04.Ended
LightPart.Material = "Metal"
LightPart.PointLight.Enabled = false
LightPart.SpotLight.Enabled = false
LightPart["Buzzing lights"]:Stop()
end
local function PersonalLightFlickerOnFunc(LightPart)
repeat
LightPart.Material = "Neon"
LightPart.PointLight.Enabled = true
LightPart.SpotLight.Enabled = true
task.wait(0.1)
LightPart.Material = "Metal"
LightPart.PointLight.Enabled = false
LightPart.SpotLight.Enabled = false
task.wait(0.3)
until
game.SoundService.light_flicker_04.Ended
LightPart.Material = "Neon"
LightPart.PointLight.Enabled = true
LightPart.SpotLight.Enabled = true
LightPart["Buzzing lights"]:Play()
end
Detector.Touched:Connect(function()
if debounce == false then
debounce = true
game.SoundService.light_flicker_04:Play()
for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
if v.Name == "FunctionalLight" then
local MainLight = v.Light
coroutine.wrap(PersonalLightFlickerOffFunc(MainLight))()
end
end
game.SoundService.ScarySoundsFolder["Metal Groans 1 (SFX)"]:Play()
wait(game.SoundService.ScarySoundsFolder["Metal Groans 1 (SFX)"].TimeLength-5)
game.SoundService.light_flicker_04:Play()
for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
if v.Name == "FunctionalLight" then
local MainLight = v.Light
coroutine.wrap(PersonalLightFlickerOnFunc(MainLight))()
end
end
end
end)