Kill 4 dummys to destroy part but its not working

I want to making if 4 dummy died then destroy a part

but its not working (its maybe because I don’t learn enough)

I try method:
function ded()
game.workspace.part:destroy()
end
game.workspace,dummy.humanoid.died:connect()
game.workspace,dummy2.humanoid.died:connect()
game.workspace,dummy3.humanoid.died:connect()
game.workspace,dummy4.humanoid.died:connect()

its working but when i kill anyone dummy then part will destroy

tesss

try again

cant upload gif but script not working

try this:

local num = 0
function Died()
      num = num + 1
     if num == 4 then
             workspace.part:Destroy()
       end
end
local Names = {"dummy","dummy2","dummy3","dummy4"}
for _,child in ipairs(workspace:GetChildren()) do
       if table.find(Names,child.Name) then
             child.Humanoid.Died:Connect(Died)
       end
end

Also, please don’t use: LowerCase Destroy, connect, Connect without arguments and , instead of .

3 Likes

i dont understand this script
but its still not working :thinking:

Are there any erros? Also, you need to learn basics before trying to script.

Try this, maybe: This just deletes the door if the Dummies are not existing anymore if yes, then its gonna return nil.

local NPCs = {workspace.Dummy, workspace.Dummy2, workspace.Dummy3, workspace.Dummy4}

if NPCs[1] or NPCs[2] or NPCs[3] or NPCs[4] == nil then do
    	game.workspace.ItsDoor:Destroy()
    end
else
	return nil
end
2 Likes

thank you for recommended
im gonna learn script more

Your script doesn’t make any sense, when the Humanoid Dies the npc isn’t deleting itselfs only the event is fired, that will make your code being like this:

if NPCs[1] == true or NPCs[2] == true or NPCs[3] == true or NPCs[4] == nil then do
    	game.workspace.ItsDoor:Destroy()
    end
else
	return nil
end

Also, the “else return nil” doesn’t do anything.

yes i tried when i start game part will destroy outright :sweat_smile:

Did that work for you or what? I’m guessing not.

Just change like this:

if game.Workspace.Dummy.Humanoid.Health == 0 and 
game.Workspace.Dummy2.Humanoid.Health == 0 and  
game.Workspace.Dummy3.Humanoid.Health == 0 and  
game.Workspace.Dummy4.Humanoid.Health == 0 then
-- Destroy the part
end

That code from the image doesn’t make any sense, Died is a Signal not a bool.

local function CreateRoom(Door, Targets)
    local count = 0;
    for i,v in ipairs(Targets) do
        v.Humanoid.Died:Connect(function() count = count + 1; if count == #Targets and Door then Door:Destroy() end end) -- Pretty sure .Died doesn't fire multiple times.
    end
end

CreateRoom(workspace.ItsDoor, {workspace.Dummy, workspace.Dummy2, workspace.Dummy3, workspace.Dummy4})

Not trying to argue but this ^ did work fine
https://gyazo.com/0b1136e605202dca976f03c8aab872e8

Your code is pretty inneficient and it is doing the same thing like mine but with a bigger wait and inneficient things like wait() without arguments and pairs instead of ipairs. Please check ur code before sending it.

Just being racist.

You just edited your issues and made more issues. Now your script will not even destroy the part.

image
Are you both breaking the rules?

1 Like

We are not breaking rule 3, but as you see if there was a rule about being racist he is 100% breaking that

Please don’t argue in a topic, do it in the DMs. These types of conversation are off topic.

2 Likes

You can use variables and while true do loop here is a simple example:

local FirstDummy = false
local SecondDummy = false
local ThirdDummy = false
local FourthDummy = false

while true do
    if FirstDummy ~= false and SecondDummy ~= false and ThirdDummy ~= false and FourthDummy ~= false then
       game:GetService("Workspace"):FindFirstChild("ItsDoor"):Destroy()
       FirstDummy = false
       SecondDummy = false
       ThirdDummy = false
       FourthDummy = false
    end
    wait(0.1)
end

script.Parent.Dummy.Humanoid.Died:Connect(function()
      FirstDummy = true
end)

script.Parent.Dummy2.Humanoid.Died:Connect(function()
      SecondDummy = true
end)

script.Parent.Dummy3.Humanoid.Died:Connect(function()
      ThirdDummy = true
end)

script.Parent.Dummy4.Humanoid.Died:Connect(function()
      FourthDummy = true
end)

Try @TheTurtleMaster_2 ‘s script again but capitalize the letter d in the dummy names within the table

local Names = {"dummy","dummy2","dummy3","dummy4"}

to:

local Names = {“Dummy”, “Dummy2”, “Dummy3”, “Dummy4”}

Also, what do you not understand about his script?

He din’t learn enouth of the basics, and also you forgot at Dummy3 one "

I fixed it right before you sent it. Im not sure how I missed these typos anyways.