I am cloning zombies from a template zombie (held in the Lighting) for a game I am building. When the zombies are cloned, then teleported, the zombie spawns dead and in pieces! This is the teleport and spawn portion of the script:
01 | wait(math.random ( 1 , ( 8 * RoundNum.Value))) |
02 | local Zombie = game.Lighting.TemplateZombie:Clone() |
03 | Zombie.Name = " " |
04 | Zombie.Enemy.MaxHealth = 100 * RoundNum.Value |
05 | Zombie.Enemy.Health = Zombie.Enemy.MaxHealth |
06 | local choices = game.Workspace.spawnPads:GetChildren() |
07 | local teleportto = (choices [ math.random( 1 ,#choices) ] ) |
08 | if teleportto~ = nil then |
09 | local torso = Zombie.Torso |
10 | local location = teleportto.Position |
11 |
12 | local x = location.x |
13 | local y = location.y |
14 | local z = location.z |
15 |
Note that the "joints" are snaps. I checked and the zombies max health is at 100 (what is should be) Joints are labeld Neck, Left Hip, Left Shoulder, Right Hip, and Right Shoulder. When copied template zombie comes out of the spawn pad, it only has it's Neck left.
I've had this problem before in the past, and the solution was to have an >:MakeJoints() after you place the model in a different parent space, like Workspace.
01 | wait(math.random ( 1 , ( 8 * RoundNum.Value))) |
02 | local Zombie = game.Lighting.TemplateZombie:Clone() |
03 | Zombie.Name = " " |
04 | Zombie.Enemy.MaxHealth = 100 * RoundNum.Value |
05 | Zombie.Enemy.Health = Zombie.Enemy.MaxHealth |
06 | local choices = game.Workspace.spawnPads:GetChildren() |
07 | local teleportto = (choices [ math.random( 1 ,#choices) ] ) |
08 | if teleportto~ = nil then |
09 | local torso = Zombie.Torso |
10 | local location = teleportto.Position |
11 |
12 | local x = location.x |
13 | local y = location.y |
14 | local z = location.z |
15 |
Hope this helps!