Children are not detected in GetChildren()

I am making a Zombie Horde game, and the Zombies are controlled by one script, they work pretty well. However when I try to add in new Zombies into the Zombies folder, they aren’t affected by the script and just stand in place.

local function update()
	for i,v in pairs(workspace.Zombies:GetChildren()) do
	--stuff goes here
	end
end

while true do
	update()
	task.wait()
end

This is basically how I handle it, the Zombies are models that have Humanoids if that helps. But more on my issue, I even tested with making the Heads transparent if they’re afffected, and the Heads don’t turn transparent.

local function update()
	for i,v in ipairs(workspace.Zombies:GetChildren()) do
	--stuff goes here
	end
end

workspace.Zombies.ChildAdded:Connect(function()
	update()
end)

Alright I found some sort of way to work with this, thanks.

1 Like

What does task.wait() do? How did you fix the issue?

task.wait() is a faster version of wait, and I figured out that while I exactly didn’t get a solution, I only now just discovered the ChildAdded function existed, figured out what to do with that.

1 Like

That’s cool. I didn’t realize it was a built in method.

The childadded function is super useful! Glad you found it.