I'm trying to make a Boss spawn system, When all the regular zombies dies it spawns the boss.
This is the script i'm using:
if game.Workspace:FindFirstChild("Zombie") == nil then --Zombie is the regular zombie print("No Zombie") --Prints No Zombie end
I dont know why it's not working so please help me, I dont need the boss spawning because I know how to make it.
Thanks, MajinBluee
Instead of a loop, you can use the ChildRemoved
event.
example:
workspace.ChildRemoved:connect(function(instance) local children = workspace:GetChildren() for i = 1, #children do if (children[i].Name == "Zombie") then print("there are " .. i .. " zombies left") elseif not workspace:FindFirstChild("Zombie") then print("no zombies left") end end end)
If you prefer a loop:
repeat wait(1) print("zombies still alive") until not workspace:FindFirstChild("Zombie")
repeat wait() if game.Workspace:FindFirstChild("Zombie") == nil then print("No Zombies") end until game.Workspace:FindFirstChild("Zombie") ~= nil print("Zombie!")
while wait() do if game.Workspace:FindFirstChild("Zombie") == nil then print("No Zombie") end end
Let me tell you why... Cuz your code has detect once and detect in a little little moment xD Hope its helped you!