Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a wave spawn timer?

Asked by 6 years ago

I wanted to know how I could make a wave timer where after a certain number ( seconds,minutes,hours, etc.) it would spawn zombies or something.

0
wait(120) hellmatic 1523 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I assume you want them to spawn in the same place, if so do this:

What you should do is make a folder in ServerStorage called NPC, in that folder (If you have more than 1 NPC type) put Folders called your NPCs Types (e.g Zombies), and in that folder put your NPCs (position them in the workspace first!). Then, in a script (probably in workspace), put this code:

while true do
    wait(time)
    for _, zombie in ipairs (game.ServerStorage.NPC.Zombies) do
        zombie:Clone().Parent = game.Workspace
    end
end

What it does is makes an infinite loop, and in that loop waits a certain amount of time, then uses a for loop to clone each zombie and place it in the workspace.

0
You should use :GetChildren() and pairs instead of ipairs. The for loop won't work unless you give it a table. ThatPreston 354 — 6y
0
What if I wanted to make it so that a certain round spawns more zombies of a certain type? Timbawolf1 6 — 6y
0
as in random? use math.random ronitrocket 120 — 6y
Ad

Answer this question