I’m attempting at scripting a L4D2 Horde Event, however I am unable to make it so that the game can spawn random amounts of Infected. For example, 6 Infected spawn as a cluster, later on, 9 more spawn. There is no set number of infected to spawn at once. Please, bare with me as I am very new to scripting.
The issue is that I cannot find a way to spawn a somewhat random amount of Infected. I’ve tried using math.random to make it seem like it is spawning a random amount, however, that never worked. Instead, I want a direct approach simply spawning a random amount, not set amount via math.random.
while true do
math.random(1-2)
if math.random == 2 then
game.ServerStorage.Zombie:Clone().Parent = game.Workspace.SpawnLocation
repeat
until wait(10)
if math.random == 1 then
game.ServerStorage.Zombie:Clone().Parent = game.Workspace.Spawn1
repeat
until wait(15)
end
end
end
(Example of what I tried to do with math.random)
I’ve tried looking up ways to spawn random amounts, though it seems like nobody has posted something like spawning random amounts of NPCs. The DevHub did give me a clue on what I should’ve done, but it wasn’t fit for what I wanted.
Also, it would be favorable if you could include which values do which, It would help me a lot.