Hi I want to make a mob spawner similar to Islands'. I'm just asking if anyone has any ideas on how to achieve this? I want to make a spawner that spawns in a mob when the already spawned in mob is killed. If you want an example, you can look at Islands' slime spawner system. I don't really want code, just an idea of how it would work.
Thanks!
Hello,
If the script above by "imnotaguest1121" did not work then try out my idea!
Connect Function When NPC Dies
Make a spawner anywhere in the map wherever you want and make the Zombie NPC and parent it to ReplicatedStorage. Make a script in the Zombie that connects a function()
to an Humanoid.Died
Event when zombie dies, you can obtain that by:
Humanoid.Died:Connect(function() -- script here end)
When the humanoid dies what you can do is Clone()
the Zombie from ReplicatedStorage and set the position of the zombie to the spawner's Position. After about 2 - 5 seconds after the Zombie death you can :Destroy
the Zombie.
Specific Amount Of NPC's
If you want a specific amount of Zombies, lets say about 5 then you can put the new cloned NPC's in a NPC folder and then count the children and add one if there is not enough Zombies, this will be obtained by:
-- References -- local NPCFolder = game.Workspace.NPCFolder local NPC = game.ReplicatedStorage.Zombie local MaxZombies = 5 -- functions -- while wait(0.5) do if #NPCFolder:GetChildren() < ( MaxZombies + 1 ) then -- Counts Zombies local NewNPC = NPC:Clone() -- Clones Zombie NewNPC.Parent = game.Workspace.NPCFolder -- Parents Zombie to folder NewNPC.Position = Spawner.Position + Vector3.new(0,4,0) -- Sets Position end end
Spawn a NPC after the Old NPC's Death
if you want one or more Zombies but they spawn after the Zombies in Workspace die what you can do is:
-- Variables -- local Humanoid = script.Parent:FindFirstChild("Humanoid") local NPC = game.ReplicatedStorage.Zombie local Spawner = game.Workspace.Spawner -- functions -- Humanoid.Died:Connect(function() -- connect function when Zombie dies local NewNPC = NPC:Clone() -- Clones NPC NewNPC.Parent = game.Workspace -- Parents NPC to Workspace NewNPC.Position = Spawner.Position + Vector3.new(0,4,0) -- Sets position wait(3) script.Parent:Destroy -- Destroys previous Zombie end)
More On Humanoid.Died
I hope this Helps!
Oh sorry! I didn't read that, anyway here Is a simple script:
local NPC = game.ReplicatedStorage. --ObjectNameHere local spawner = script.Parent while true do local Clone = NPC: Clone() Clone.Parent = workspace Clone.Torso.CFrame = spawner.CFrame wait(3) end