#how can I make spawn cap not break script

11 messages · Page 1 of 1 (latest)

strange forge
#
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local pingas = game.Workspace:WaitForChild("Pingas")
local juan = ReplicatedStorage:WaitForChild("Drooling Zombie")
local spawns = {pingas.P1, pingas.P2, pingas.P3, pingas.P4, pingas.P5, pingas.P6, pingas.P7, pingas.P8}
local cap = 5
local CF = 0

while true do
    local rng = math.random(1, #spawns)
    local pawn = spawns[rng]
    print(pawn)

    local hwan = juan:Clone()
    CF += 1
    if CF <= cap then
        hwan.Parent = game.Workspace.Pingas.zomboss
        hwan.PrimaryPart = hwan.Torso
        if hwan.PrimaryPart then
            hwan:SetPrimaryPartCFrame(pawn.CFrame)
        else
            warn("Juan model does not have a PrimaryPart set.")
        end
        task.wait(1)
    else
        warn("Max")
        break
    end
end```
#

sorry for the braindamage of the variable names

glass flare
#
`lualocal ReplicatedStorage = game:GetService("ReplicatedStorage")
local pingas = game.Workspace:WaitForChild("Pingas")
local juan = ReplicatedStorage:WaitForChild("Drooling Zombie")
local spawns = {pingas.P1, pingas.P2, pingas.P3, pingas.P4, pingas.P5, pingas.P6, pingas.P7, pingas.P8}
local cap = 5
local CF = 0

while true do
    local rng = math.random(1, #spawns)
    local pawn = spawns[rng]
    print(pawn)

    local hwan = juan:Clone()
    CF += 1
    if CF <= cap then
        hwan.Parent = game.Workspace.Pingas.zomboss
        hwan.PrimaryPart = hwan.Torso
        if hwan.PrimaryPart then
            hwan:SetPrimaryPartCFrame(pawn.CFrame)
        else
            warn("Juan model does not have a PrimaryPart set.")
        end
        task.wait(1)
    else
        warn("Max")
        break
    end
end
strange forge
#

did you change it?

glass flare
#

Wanna break the while loop?

strange forge
#

I want it to not break permanently

glass flare
#

What's error

strange forge
#

there is no error

#

tldr when zombie dies and amount alive is under cap, it's still broken

#

how could I make it detect if a zombie dies