Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How Do I Stop Cloned AI From Losing Joints?

Asked by
jacobwow 140
8 years ago

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:

01wait(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 
View all 25 lines...

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.

1 answer

Log in to vote
1
Answered by 8 years ago

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.

01wait(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 
View all 26 lines...

Hope this helps!

0
Thanks! At first it didn't work, but I moved the Zombie.Parent = game.Workspace and Zombie:MakeJoints() before line 06 and it worked! jacobwow 140 — 8y
Ad

Answer this question