I'm trying to get a zombie spawning script but when it spawns, it dies automatically.
waittime = 60 -- 1 min
function StartCountdown()
waittime = 60 -- Reset the waittime everytime you start a countdown
for i =1,60 do -- for 1, 60 times do -- This can be done differently, i.e repeat -code- until
waittime = waittime - 1 -- Minus 1 every second
wait(1)
end
SpawnZombie() -- Spawn a zombie after the for loop is finished
StartCountdown() -- In Another min another zombie will be spawned
end
function SpawnZombie()
local Zombie = game.Lighting.Zombie:Clone() -- Assuming its in the lighting and its name is Zombie
Zombie.Parent = game.Workspace -- You can place the zombie in an appropriate spot and just parent them to workspace when spawning(Easiest way)
for i,v in pairs(Zombie:GetChildren()) do -- This gets the scripts in the zombie and enables them(Keep the scripts in the Zombie Disabled so they dont brake while in the lighting)
if v:IsA("Script") then
v.Disabled = false
end
end
end
StartCountdown() -- Run the function to start the game/round

8 comments
What if it's in lightning? Just do the same thing?
Nevermind, going to put it in workspace again
Also,what if the script makes it spawn multiple times?
Yes, it's fine if you keep the zombie backup Lighting. Just add that line right after the Zombie.Parent = game.Workspace line. Hope this helps!
So It's supposed to look like Zombie.Parent = game.Workspace -- You can place the zombie in an appropriate spot and just parent them to workspace when spawning(Easiest way)
Linebreak then put Zombie:MakeJoints()?
Sorry if this bugs you or not, but How do I move the spawn location up a little? Because It's working and all but It spawns stuck in the ground.
As it is, it's not changing the zombie's position at all. It will simply move a copy from lighting to Workspace. To change that position, pu t the zombie in workspace where you want it to spawn, then put it back in lighting. You can do this by cutting, Cntrl+X, and then right clicking lighting and using "Paste into".