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

Player Clone doesnt work?

Asked by 9 years ago

I tried making a copy of myself as for a shadow clone jutsu. Is there a way to make it work? Feel free to add on to the script.

player = game.Players.LocalPlayer
mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
    if key:lower() == "x" then
        local clone = player.Character:Clone()
        clone.Parent = game.Workspace
        clone.Position = player.Character.Torso.Position + Vector3.new(5, 0, 5)
    end
end)

1 answer

Log in to vote
3
Answered by 9 years ago

For some reason you cannot clone the character, So the only way to do this is by cloning everything on the inside of the character and inserting it into a model with the same name as the character:


Final Product

Use UserInputService instead of KeyDown since KeyDown is deprecated.

--LocalScript
local uis = game:GetService("UserInputService")
local plyr = game:GetService("Players").LocalPlayer

uis.InputBegan:connect(function(key,processed)
    if key.KeyCode == Enum.KeyCode.X and not processed then
        local m = Instance.new("Model",workspace)
        for _,obj in pairs(plyr.Character:GetChildren()) do
            obj:clone().Parent = m
        end
        m.Name = plyr.Name
        m:MakeJoints()
    end
end)

Hope it helps!

Ad

Answer this question