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

3 comments
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.
clone is deprecated, use Clone
Yes, but that still doesn't resolve this issue. Thanks though!