Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I check if there's a specific children in Workspace?

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

1 comment

0

Ohhh I know why it's not working, But thanks to you all who wanted to help me.

3 answers

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")

2 comments

0

the print("there are "..i.." zombies left") isn't going to display the correct number, just saying.

0

print(#children[i])

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!

1 comment

0

It doesn't work :(

This discussion is preserved as it was. New answers, comments, and votes are closed.