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

My code is supposed to clone characters, but instead errors! Help?

Asked by 6 years ago

So I'm trying to make a zombie script where anyone that dies gets infected. In order to do this, I need to clone the player but I get this error message saying;

16:38:33.643 - Workspace.Arcerion.zombify:5: attempt to index local 'zombie' (a nil value)

So the issue with this, I assume is because Roblox doesn't allow cloning a player's character, but I've seen people do it before. Now I could always create a npc that transforms into the character, but I know that there's another way to do this.

Here is the code I've sent, it's really simple because let's be honest when I script and run into an issue I want to solve it before continuing. I just can't resolve this issue, so I'm asking for help.

Code;

local character = script.Parent

local zombie = character:clone()

zombie.Parent = workspace

local rooty = character:FindFirstChild("HumanoidRootPart")


if rooty ~= nil then

    zombie:MoveTo(rooty.Position)

end
0
Also this script goes into the character, then is supposedly supposed to clone the character. That's why character = script.Parent so keep that in mind. Lem0nzzXI 57 — 6y
0
clone is deprecated, use Clone green271 635 — 6y
0
Yes, but that still doesn't resolve this issue. Thanks though! Lem0nzzXI 57 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

By doing some reading of your code, I got your solution. The issue of your code is that you did not enable Archivable which is a property of the characters model. So if you do:

local character = script.Parent

character.Archivable = true

local zombie = character:Clone()

character.Archivable = false

zombie.Parent = workspace

local rooty = character:FindFirstChild("HumanoidRootPart")


if rooty ~= nil then

    zombie:MoveTo(rooty.Position)

end

That should do it, let me know if you have anymore issues!

0
So when you enable "Archivable" it allows it to be cloned? I'll give that a try, and if it works I got myself an answer! Lem0nzzXI 57 — 6y
0
Thanks! I appreciate your help, and if there's any you need don't mind contacting me, I'll probably add you on Roblox as well! Lem0nzzXI 57 — 6y
Ad

Answer this question