ok so i got the spawner it is just that i only want it to spawn the npc when the previous one has died this is my current script so far:
local guards = game.ReplicatedStorage.Guards for _,i in pairs(guards:GetChildren()) do local clone = i:Clone() clone.Parent = workspace.Guards clone.Humanoid.Died:Connect(function() end) end
game.ReplicatedStorage.Guards is a folder that contains a lot of guards or at least is going to rn it only has one so right now i don't even think this will work because once the loop has finished im not sure if it will even run when it dies and second im not sure what to put when the thing has died because i would put local clone = bla bla bla then i would put clone.hum.died:connec and in that i would have to put that in and do that forever and ever so is there any way to fix those two problems? i was thinking i could fire a remote event but i would need to fire it back agian in a client cause there both in server anyway is there any way to fix this?
Why didn't you write a recursive function for respawn?
local guards = game.ReplicatedStorage.Guards function recursiveSpawn(i) local clone = i:Clone() clone.Parent = workspace.Guards clone.Humanoid.Died:Connect(function() recursiveSpawn(i) end) end for _,i in pairs(guards:GetChildren()) do recursiveSpawn(i) end