So basically I have some code that detects a fire
while wait(5) do
for _,Detected in pairs(workspace:GetDescendants()) do
if Detected:IsA('Fire') then
s_5:Play()
wait(5)
s_1:Play()
for _,sprinkler in pairs(Sprinklers:GetDescendants()) do
if sprinkler:IsA('ParticleEmitter') then
sprinkler.Enabled = true
end
end
s_2:Play()
s_3:Play()
s_4:Play()
end
end
end
However, it’s in a loop because without the loop, the fire doesn’t get detected. This is annoying though because the sounds get played again after 5 seconds when they are already on loop.
How can I fix this? I just need it to constantly detect fires but only turn the sound and sprinklers on once. I tried break statements, bool values but nothing worked.
Thanks!