of     1   

milanomaster
#227619802Friday, November 17, 2017 12:17 AM GMT

I've been trying to make a script for when all x enemies are killed, a door opens. I got this, but it's not working. (no errors) How do I fix this? Thanks in advance. EnemyOneKilled = false EnemyTwoKilled = false EnemyThreeKilled = false EnemyFourKilled = false EnemyFiveKilled = false EnemySixKilled = false local e1 = script.Par ent.Par ent.Par ent["Boomer"].Zombie -- (parent* tags) local e2 = script.Par ent.Par ent.Par ent["Boomer2"].Zombie local e3 = script.Parent.Parent.Parent["Glaciator"].Zombie local e4 = script.Parent.Parent.Parent["Glaciator2"].Zombie local e5 = script.Parent.Parent.Parent["Healer"].Zombie local e6 = script.Parent.Parent.Parent["Viking"].Zombie e1.Died:Connect(function() EnemyOneKilled = true end) e2.Died:Connect(function() EnemyTwoKilled = true end) e3.Died:Connect(function() EnemyThreeKilled = true end) e4.Died:Connect(function() EnemyFourKilled = true end) e5.Died:Connect(function() EnemyFiveKilled = true end) e6.Died:Connect(function() EnemySixKilled = true end) function AllEnemiesCleared() if EnemyOneKilled == true and EnemyTwoKilled == true and EnemyThreeKilled == true and EnemyFourKilled == true and EnemyFiveKilled == true and EnemySixKilled == true then script.Sound:Play() print('gg') script.Parent.Transparency = 1 script.Parent.CanCollide = false end end
King_Snazzy
#227619896Friday, November 17, 2017 12:21 AM GMT

Try setting a while true loop for the AllEnemiesCleared function? Laissez faire, morbleu ! Laissez faire!
Laedere
#227619936Friday, November 17, 2017 12:23 AM GMT

you need to learn about dictionaries
milanomaster
#227620022Friday, November 17, 2017 12:26 AM GMT

@King_Snazzy, It is probably going to keep playing the sound and such. Do you think 'script:Destroy()' is an option? @Laedere, Mind telling me how those dictionaries work?
King_Snazzy
#227620780Friday, November 17, 2017 12:52 AM GMT

Yeah, destroying the script after all of the values are true is an option. Make sure you add a wait() if you want to make a loop, though. Laissez faire, morbleu ! Laissez faire!
WillieTehWierdo200
#227622583Friday, November 17, 2017 1:49 AM GMT

local zombieTypes = script.Parent.Parent.Parent local zombies = { zombieTypes.Boomer, zombieTypes.Boomer2, zombieTypes.Glaciator, zombieTypes.Glaciator2, zombieTypes.Healer, zombieTypes.Viking } local deadZombies = {} local door = script.Parent for _, zombie in ipairs(zombies) do local zombieHumanoid = zombie.Zombie zombieHumanoid.Died:Connect(function() deadZombies[zombie] = true end) end function AllEnemiesCleared() for _, zombie in ipairs(zombies) do if not deadZombies[zombie] then return false end end return true end while not AllEnemiesCleared() do wait(1) end print("gg") script.Sound:Play() door.Transparency = 1 door.CanCollide = false
milanomaster
#227634222Friday, November 17, 2017 1:48 PM GMT

Thanks a lot! I'll be trying to figure out this script as well for the future :)

    of     1