Troop = script.Parent.HumanoidRootPart
local debouce = true

while wait() do
    local enemies = game.Workspace.Enemies:GetChildren()
    local zombieroot = enemies.HumanoidRootPart
    for i, v in pairs(game.Workspace.Enemies:GetChildren()) do
        local swing = Troop.Parent.Humanoid:LoadAnimation(script.Swing)
        if (v.HumanoidRootPart.Position - Troop.Position).magnitude <= 8.5 then
            Troop.CFrame = CFrame.new(Troop.Position, v.HumanoidRootPart.Position)
            if v.HumanoidRootPart.Parent.Dead.Value == false then
            if debouce then
                swing:Play()
                    if v.HumanoidRootPart.Parent.Dead.Value == false then
                        if v.HumanoidRootPart.Parent:FindFirstChild("Health") then
                    v.HumanoidRootPart.Parent.Health.Value = v.HumanoidRootPart.Parent.Health.Value - script.Parent.Damage.Value
                        end
                    end
                    end
                    end
                script.Parent.FirePart.Fire:Play()
                wait(0.8)
                end
            wait()
            end
            end

for some reason when the troop doesnt even aim at the zombie or even try to shoot it when its dead, and when it disappears, its acting like its trying to shoot the zombie right as it dies, making the error say that there isnt a humanoidrootpart inside of zombie when the troop wasnt even aiming at the zombie, I dont get what is going on can someone help me

i dont know if even what i said makes sense please tell me if it doesnt

edit: i kind of see the problem, if a troop shoots at the same time a zombie dies, the error occurs but i have no clue how to stop it