Oh... My bad...
function muteSounds ()
for i, sound in ipairs(getElementsByType("sound")) do
if not sound == song then
setSoundVolume(sound, 0)
end
end
end
addEventHandler("onClientResourceStart", root,
function ()
setTimer(muteSounds, 1000, 1) --To make sure that the sound is already playing
end)
OR
You could simply use timer..
function muteSounds ()
for i, sound in ipairs(getElementsByType("sound")) do
if not sound == song then
setSoundVolume(sound, 0)
end
end
end
setTimer(muteSounds, 1000, 0)