I would like if a zombie dies it respawns after a few seconds.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
-- Function to respawn a zombie
local function respawnZombie(zombie)
task.wait(2) -- Wait for 2 seconds
local newZombie = zombie:Clone() -- Clone the zombie
newZombie.Parent = Workspace -- Place the new zombie back in the workspace
newZombie:SetPrimaryPartCFrame(zombie:GetPrimaryPartCFrame()) -- Set the position to the same as the original
end
-- Function to handle zombie destruction
local function onZombieDestroyed(zombie)
zombie:Destroy() -- Destroy the original zombie
respawnZombie(zombie) -- Respawn the zombie
end
-- Connect the destruction event to the handler
Workspace.ChildRemoved:Connect(function(child)
if child:IsA("Model") and child.Name == "Zombie" then -- Assuming zombies are models named "Zombie"
onZombieDestroyed(child)
end
end)
** You are now Level 1! **