Hi, I made a module script that will run sounds by queue, but it dies on waiting and does not give an error. I tried to somehow find out exactly where this error comes from and I found it, but I couldn’t solve it in any way.
This is part of the script:
local Requests = {}
local InRunning = false
local DelayBetweenAnns = 1.5
function Run(sound,t)
task.delay(0.1,function()
local Notifications = workspace.Audios.Notifications
local NewSound
local Found = false
print("Child running!")
InRunning=true
for i,v in pairs(Notifications:GetDescendants()) do
if v.ClassName=="Sound" then
if v.Name==sound then
NewSound=v
Found=true
break
end
end
end
if Found==true then
if t~=nil then
if (t):lower()=="warhead" then
workspace.Audios.Alarm.WarheadAlarm:Play()
task.wait(4.5)
elseif (t):lower()=="announcement" then
workspace.Audios.Notifications.AnnouncementStart:Play()
task.wait(1.5)
end
end
print("a0")
NewSound:Play()
print("a1")
task.wait((NewSound.TimeLength/NewSound.PlaybackSpeed)+DelayBetweenAnns) --this is part where function is dying
print("a2")
else
warn("Error: The sound '" .. sound .."' does not found in '" .. Notifications:GetFullName() .. "'")
end
print("Child ended!")
table.remove(Requests,1)
InRunning=false
if Requests[1] ~= nil then
Run(unpack(Requests[1]))
end
end)
end
And also:

For me, this error occurs when another script requests to play different sounds several times, but on the same one sound, module script function dies