Spawn Enemies

Script

local part = script.Parent
local spawnZone = game.Workspace.Spawn

local ServerStorage = game:GetService('ServerStorage')

local canSpawn = true

local function spawnZombie(otherPart)
    local humanoid = otherPart.Parent:FindFirstChildWhichIsA('Humanoid')
    local player = game.Players:FindFirstChild(otherPart.Parent.Name)
    local enemyNum = game.Workspace.Enemies:GetChildren()
    if humanoid and player and canSpawn and #enemyNum < 5 then
        canSpawn = false
        local zombie = ServerStorage.Enemies['Drooling Zombie']:Clone()
        zombie.Parent = game.Workspace.Enemies
        zombie.HumanoidRootPart.CFrame = CFrame.new(spawnZone.Position + Vector3.new(0,5,0))
        wait(3)
        canSpawn = true
    end
end

part.Touched:Connect(spawnZombie)