How to handle mass NPC sounds?

I’ve got a zombie game that has 350 NPC’s roaming around. They all currently each play a zombie sound (growling etc) but too many sounds all playing at once causes the sounds to start cutting out and failing to play.

How should I go about handling this process?

Limit it to playing maybe 10 zombie sounds maximum. It’s hard to know how your scripts are set up, and how the zombies are actually created, but here’s something to try

local npcFolder = game.Workspace.Folder -- where are you npcs parented? or use collection service

npcFolder.ChildAdded:Connect(function()
    if #npcFolder:GetChildren() <= 10 then
        local sound = Instace.new("Sound")
        sound:Play() -- awesome
    end
end)
1 Like