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

Why is the door not opening after all the npcs die EVEN though ther are no errors?

So in EVERY other part of the map this works but its not working for this door only please help.

local npc1 = game.Workspace.ppl 
local npc2 = game.Workspace.ppl1
local npc3 = game.Workspace.ppl2
local npc4 = game.Workspace.ppl3
local npc5 = game.Workspace.ppl4
local npc6 = game.Workspace.ppl5
local npc7 = game.Workspace.ppl6
local npc8 = game.Workspace.ppl7
local npc9 = game.Workspace.ppl8
local npc10 = game.Workspace.ppl9
local npc11 = game.Workspace.ppl10
local npc12 = game.Workspace.ppl11
local npc13 = game.Workspace.ppl12
local npc14 = game.Workspace.ppl13
local npc15 = game.Workspace.ppl14
local npc16 = game.Workspace.ppl15
local npc17 = game.Workspace.ppl16
local npc18 = game.Workspace.ppl17
local npc19 = game.Workspace.ppl18
local npc20 = game.Workspace.ppl19
local npc21 = game.Workspace.ppl20
local door = game.Workspace.part5

local died = 0

npc1.tech.Died:Connect(function()
	print("died")
    died = died + 1
end)

npc2.tech.Died:Connect(function()
    died = died + 1
end)

npc3.tech.Died:Connect(function()
	died = died + 1
end)

npc4.tech.Died:Connect(function()
	died = died + 1
end)

npc5.tech.Died:Connect(function()
    died = died + 1
end)

npc6.tech.Died:Connect(function()
    died = died + 1
end)

npc7.tech.Died:Connect(function()
    died = died + 1
end)

npc8.tech.Died:Connect(function()
    died = died + 1
end)

npc9.tech.Died:Connect(function()
    died = died + 1
end)

npc10.tech.Died:Connect(function()
    died = died + 1
end)

npc11.tech.Died:Connect(function()
    died = died + 1
end)

npc12.tech.Died:Connect(function()
    died = died + 1
end)

npc13.tech.Died:Connect(function()
    died = died + 1
end)

npc14.tech.Died:Connect(function()
    died = died + 1
end)

npc15.tech.Died:Connect(function()
    died = died + 1
end)

npc16.tech.Died:Connect(function()
    died = died + 1
end)

npc17.tech.Died:Connect(function()
    died = died + 1
end)

npc18.tech.Died:Connect(function()
    died = died + 1
end)

npc19.tech.Died:Connect(function()
    died = died + 1
end)

npc20.tech.Died:Connect(function()
    died = died + 1
end)

npc21.tech.Died:Connect(function()
    died = died + 1
end)

coroutine.wrap(function()
    while wait() do
        if died == 20 then
            door.Transparency = 0.5
            door.CanCollide = false
            break
        end
    end
end)()

1 answer

✓ Accepted answer

Hello. The answer is pretty simple. It's supposed to be 21 people, not 20, so just change your if statement to if died == 21.

local npc1 = game.Workspace.ppl 
local npc2 = game.Workspace.ppl1
local npc3 = game.Workspace.ppl2
local npc4 = game.Workspace.ppl3
local npc5 = game.Workspace.ppl4
local npc6 = game.Workspace.ppl5
local npc7 = game.Workspace.ppl6
local npc8 = game.Workspace.ppl7
local npc9 = game.Workspace.ppl8
local npc10 = game.Workspace.ppl9
local npc11 = game.Workspace.ppl10
local npc12 = game.Workspace.ppl11
local npc13 = game.Workspace.ppl12
local npc14 = game.Workspace.ppl13
local npc15 = game.Workspace.ppl14
local npc16 = game.Workspace.ppl15
local npc17 = game.Workspace.ppl16
local npc18 = game.Workspace.ppl17
local npc19 = game.Workspace.ppl18
local npc20 = game.Workspace.ppl19
local npc21 = game.Workspace.ppl20
local door = game.Workspace.part5

local died = 0

npc1.tech.Died:Connect(function()
    print("died")
    died = died + 1
end)

npc2.tech.Died:Connect(function()
    died = died + 1
end)

npc3.tech.Died:Connect(function()
    died = died + 1
end)

npc4.tech.Died:Connect(function()
    died = died + 1
end)

npc5.tech.Died:Connect(function()
    died = died + 1
end)

npc6.tech.Died:Connect(function()
    died = died + 1
end)

npc7.tech.Died:Connect(function()
    died = died + 1
end)

npc8.tech.Died:Connect(function()
    died = died + 1
end)

npc9.tech.Died:Connect(function()
    died = died + 1
end)

npc10.tech.Died:Connect(function()
    died = died + 1
end)

npc11.tech.Died:Connect(function()
    died = died + 1
end)

npc12.tech.Died:Connect(function()
    died = died + 1
end)

npc13.tech.Died:Connect(function()
    died = died + 1
end)

npc14.tech.Died:Connect(function()
    died = died + 1
end)

npc15.tech.Died:Connect(function()
    died = died + 1
end)

npc16.tech.Died:Connect(function()
    died = died + 1
end)

npc17.tech.Died:Connect(function()
    died = died + 1
end)

npc18.tech.Died:Connect(function()
    died = died + 1
end)

npc19.tech.Died:Connect(function()
    died = died + 1
end)

npc20.tech.Died:Connect(function()
    died = died + 1
end)

npc21.tech.Died:Connect(function()
    died = died + 1
end)

coroutine.wrap(function()
    while wait() do
        if died == 21 then
            door.Transparency = 0.5
            door.CanCollide = false
            break
        end
    end
end)()

Please accept and upvote this answer if it helped.

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