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

Why does my NPC die after being moved from ReplicatedStorage to Workspace?

Asked by
OniiCh_n 410 Moderation Voter
10 years ago

So I have a spawning mechanism that copies an NPC from ReplicatedStorage to the Workspace. It works, but the problem is that upon being moved, it instantly dies. How do I prevent this from happening?

Image of what happens AFTER it is moved

Code of the spawning:

local zambieBox = game.ReplicatedStorage.Zombies
local zambie = zambieBox.grassPl0X
local spawner = game.Workspace.grassSpawner
local spawnPos = spawner.Position
local roundStart = spawner.roundStatus
local zambieCount = spawner.zambieCount
local currentRound = spawner.currentRound

function spawn()
    newZambie = zambie:Clone()
    newZambie.Parent = game.Workspace
    newZambie.Torso.Position = spawnPos
    newZambie.Humanoid.Health = 100
    zambieCount.Value = zambieCount.Value + 1
end

while roundStatus and zambieCount < 5*currentRound.Value do
    wait(4)
    spawn()
end
3
newZambie:MakeJoints() TheeDeathCaster 2368 — 10y
0
Do I put that inside the spawn() function? OniiCh_n 410 — 10y
0
Ya. TheeDeathCaster 2368 — 10y
1
Thanks! OniiCh_n 410 — 10y
0
No problem. TheeDeathCaster 2368 — 10y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Like TheAlphaStigma said, just add:

newZambie:MakeJoints()

To your spawn function.

Ad

Answer this question