I get no errors when executing this script can someone tell me what I'm doing wrong and fix it for me? Please and thank you.
for _, mob in pairs(workspace.Zombies.Mobs:GetChildren()) do if mob.Name == "Zombie" then mob:Destroy() end end
Try using i, v in pairs instead of _, mob in pairs:
for i, v in pairs(workspace.Zombies.Mobs:GetChildren()) do if v.Name == "Zombie" then v:Destroy() end end
Before running the for
loop, add a wait()
so that the zombies can spawn into the folder:
wait(5) -- Waits 5 seconds before the loop starts. During this time, everything has time to spawn in. for _, mob in pairs(workspace.Zombies.Mobs:GetChildren()) do if mob.Name == "Zombie" then mob:Destroy() end end