So, a part of the game is to go through a Story-progressed zombie survival game, and I really am stuck on how to spawn a set amount of randomized zombies into the workspace to hunt the player(s) by reaching a certain point (e.g. touching a part to spawn them.).
I need help on how to do this without using folders to limit spawns. (Certain weapons will not hurt the zombies if they are in a folder in the workspace.)
Any help is appreciated
Game link (It is a work in progress, no zombies spawn in the zombie game.): Game
Well, If you have the zombie model the only thing that you have to do is the following:
local amount = 10
local spawnPart = workspace.Spawn
local zombieTemplate = game.ReplicatedStorage.Zombie
local timeToWait = 2
for i = 1,10,1 do
local Zombie = zombieTemplate:Clone()
Zombie.Parent = workspace
Zombie:SetPrimaryPartCFrame(spawnPart.CFrame * CFrame.new(Vector3.new(0,4,0))
wait(timeToWait)
end
If you want to learn how to create a zombie I would check out this:
local amount = 10
local spawnPart = workspace.Spawn
local zombieTemplate = game.ReplicatedStorage.Zombie
local timeToWait = 2
local partToBeTouched = workspace.TouchPart
partToBeTouched.Touched:Connect(function(playerWhoTouched)
for i = 1,10,1 do
local Zombie = zombieTemplate:Clone()
Zombie.Parent = workspace
Zombie:SetPrimaryPartCFrame(spawnPart.CFrame * CFrame.new(Vector3.new(0,4,0))
wait(timeToWait)
end
end)
local amount = 10
local spawnParts = {workspace.Spawn0, workspace.Spawn1, workspace.Spawn3}
local zombieTemplate = game.ReplicatedStorage.Zombie
local timeToWait = 2
local partToBeTouched = workspace.TouchPart
partToBeTouched.Touched:Connect(function(playerWhoTouched)
for i = 1,10,1 do
local Zombie = zombieTemplate:Clone()
Zombie.Parent = workspace
Zombie:SetPrimaryPartCFrame(spawnParts[math.random(1, #spawnParts)].CFrame * CFrame.new(Vector3.new(0,4,0))
wait(timeToWait)
end
end)
local amount = 10
local spawnPart = workspace.Spawn
local zombieTypes = {game.ReplicatedStorage.Normal, game.ReplicatedStorage.Fire, game.ReplicatedStorage.Water}
local timeToWait = 2
local partToBeTouched = workspace.TouchPart
partToBeTouched.Touched:Connect(function(playerWhoTouched)
for i = 1,10,1 do
local Zombie = zombieTypes[math.random(1, #zombieTypes)]:Clone()
Zombie.Parent = workspace
Zombie:SetPrimaryPartCFrame(spawnPart.CFrame * CFrame.new(Vector3.new(0,4,0))
wait(timeToWait)
end
end)
In roblox, touching a part is not an event that will fire when you touch it for the first time!
It will fire when you move while in contact with the part. So if you walk on the part, it will fire multiple times. You would have to add a cooldown.