So I have a script in workspace that will clone zombies to a certain point in wave increments (every wave spawns more zombies) the problem is when I tested this as soon as the zombies teleport they die, is there any suggestions on how to fix this. I use MoveTo:() for teleporting the zombies and then I teleport their model. If you have any suggestions please tell me. Here is the code: (random map basically picks a randomap to spawn which is done above this, it is not important but when teleporting them they must teleport to [randommap].ZombieSpawn1)
The variable zombie found in local zombieclone = zombie:clone() is game.Lighting.Zombie
repeat wait(10) local wavenum = script.Wave wavenum.Value = wavenum.Value +1 topgui.Value = "Wave " ..wavenum.Value.. "!" local zoms = math.random(5,10) local zomsfinal = zoms*wavenum.Value for spawn1 = 0, zomsfinal do local zombieclone = zombie:clone() zombieclone.Parent = game.Workspace[randommap] zombieclone:MoveTo(game.Workspace[randommap].ZombieSpawn1.Position) print("zombiespawn1 spawned") wait(2) end until gameover.Value == true
You need to use the MakeJoints method to well, make its joints! When cloning a model that contains parts within it, you need to bond all of its joints back together!
repeat wait(10) local wavenum = script.Wave wavenum.Value = wavenum.Value +1 topgui.Value = "Wave " ..wavenum.Value.. "!" local zoms = math.random(5,10) local zomsfinal = zoms*wavenum.Value for spawn1 = 0, zomsfinal do local zombieclone = zombie:clone() zombieclone:MakeJoints() zombieclone.Parent = game.Workspace[randommap] zombieclone:MoveTo(game.Workspace[randommap].ZombieSpawn1.Position) print("zombiespawn1 spawned") wait(2) end until gameover.Value == true