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

How do you fix it?, the Zombies do not get destroyed. Did I make any mistakes?

local rep = game.ReplicatedStorage
local zombies = game.Workspace.Zombies:GetChildren()


rep.Died.OnServerEvent:Connect(function(player)
	for i = 1, #zombies do
		zombies[i]:Destroy()
		game.Workspace.Spawns.Script.Disabled = true
				
	end
end)


rep.resurrect.OnServerEvent:Connect(function(player)
	game.Workspace.Spawns.Script.Disabled = false
end)

6 comments

1

line 6 use for i, v in ipairs(zombies) do end

0

You provided very little information. I don't know what (game.Workspace.Spawns.Script) is. Is it the script you're currently writing in?

0

try what markedtomato said and then do v:Destroy()

0

It is the folder where the spawn part are for the zombies

0

you can try using :ClearAllChildren, when only the zombies are in the model/folder

0

It worked, thank you. @PokeCrafterC

2 answers

local rep = game.ReplicatedStorage
local zombies = game.Workspace.Zombies:GetChildren()


rep.Died.OnServerEvent:Connect(function(player)
    for _, zombiezz in pairs(zombies) do
        zombiezz:Destroy()
        

    end
	game.Workspace.Spawns.Script.Disabled = true
end)


rep.resurrect.OnServerEvent:Connect(function(player)
    game.Workspace.Spawns.Script.Disabled = false
end)
local rep = game.ReplicatedStorage
local zombies = game.Workspace.Zombies


rep.Died.OnServerEvent:Connect(function(player)
	zombies:ClearAllChildren()
   game.Workspace.Spawns.Script.Disabled = true
end)


rep.resurrect.OnServerEvent:Connect(function(player)
	game.Workspace.Spawns.Script.Disabled = false
end)

This works, thank you all for your help

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