I need a zombie spawn script

Hello so I need a script that when you click a block a zombie npc spawns.
I have tried to get tutorials on how to do it but I cant find any and I have tried to mod roblox’s zombie spawner so if anyone can I help me then many thanks.

1 Like

an npc that attacks or just stand still?

1 Like

put an npc in rep storage
Add a part, parent a click detector and a script to it
write in script:

     local zombie = game.ReplicatedStorage["INSERT NPC NAME HERE"]
     zombie.Parent = workspace
     zombie.HumanoidRootPart.CFrame = script.Parent.CFrame
end)
2 Likes

also put

script.Parent.ClickDetector.MouseClick:Connect(function()

in front of it

1 Like

If you want it to loop forever:

task.spawn(function()
while true do
local zombieClone = game.ReplicatedStorage.Zombie:Clone()
zombieClone.Parent = workspace

task.wait(5)
end
end)

If you want it to repeat 50 times:

for i = 1,50 do
local zombieClone = game.ReplicatedStorage.Zombie:Clone()
zombieClone.Parent = workspace

task.wait(5)
end
2 Likes

I need it to kill People to.
So when they click it it spawns a amount.

1 Like

Get a zombie out of the Toolbox and just use their scripts.

1 Like

It works thanks but I need it to spawn at a different position and not on the button so how would that be done.

When you Clone the zombie from rep Storage just set the CFrame of the Humanoid Root Part of the zombie to a desired position in the workspace. HumanoidRootPart.CFrame = CFrame.new(Position you want it.)

1 Like

Thanks it works but when I click the block again it doesn’t spawn a new zombie I don’t know for sure but do I need a clone part in the script and if so can you show me what it needs to look like.

Edit: I found a fix for it so just do this:

script.Parent.ClickDetector.MouseClick:Connect(function()

local zombie = game.ReplicatedStorage["Zombie"]:Clone()

zombie.Parent = workspace

zombie.HumanoidRootPart.CFrame = script.Parent.CFrame

end)
1 Like
script.Parent.ClickDetector.MouseClick:Connect(function()

local zombie = game.ReplicatedStorage["Zombie"]:Clone()

zombie.Parent = workspace

zombie.HumanoidRootPart.CFrame = Vector3.new(0, 0, 0)

end)

Set the Vector3.new(0, 0, 0) to whatever coords you want it to spawn at if you want it specific

1 Like

An easier solution would be to place parts all around the Workspace and set the CFrame of the zombie’s HRP to the Part’s CFrame

1 Like

Same difference, going to get the same outcome

1 Like