:Clone() is not cloning the children of a model

Hello, i’m having a problem with the Clone() Function.
Basically, i’m trying to clone the player’s character so it can be shown in a ViewportFrame.

My code works fine until the cloning itself. The player model is cloned and put in the right location, however, no childs are cloned, which makes cloning the model useless. I can’t figure out why this happens, can someone help me? or is this an engine bug?

Code:

local NewCharacter
local Camera = Instance.new("Camera")
local Viewport = script.Parent:WaitForChild("ViewportFrame")
Camera.Parent = script
local Player = game:GetService("Players").LocalPlayer
print(Player)
local Character = Player.Character
Character.Archivable = true
local NewCharacter = Character:Clone()
print(NewCharacter)
NewCharacter.Parent = workspace
NewCharacter.Torso.Position = Vector3.new(0,0,0)
Camera.CameraSubject = NewCharacter.Humanoid
2 Likes

Make sure that the character’s children are archivable, too.

1 Like

Every single one is Archivable, as shown right here:

2 Likes

Is this a local script?
If so try directly and parent the new character.

local new=game.Players.LocalPlayer.Character:Clone()
new.Parent=game.workspace
1 Like

Are you sure that the camera is pointing the right way? You didn’t set the CFrame of the camera at all! Setting the CameraSubject does nothing.

Try running the following code and see if this changes anything:

Camera.CFrame = CFrame.new(Vector3.new(0, 0, 10), Vector3.new(0, 0, 0))

This positions the camera at (0, 0, 10), oriented in such a way that it faces (0, 0, 0).

1 Like

Childs are not appearing in explorer, and any reference to child errors.


see that second model without any children? It’s the clone.

2 Likes

Apparently all parts did not exist in the first place. You should do this:
Character:WaitForChild("Torso") or wait()

Or any yielding, because you only have the model first, not the children themselves.

6 Likes

Just tried it, the childs also didn’t get cloned.

1 Like

I don’t know what else could be wrong…

Try printing the children of thecharacter right before cloning. It’s possible that the character hasn’t been built yet when the script runs.

1 Like

Just tried that, the valid childs got cloned, now trying to clone the clothing, and hats, which refuse to be cloned

1 Like

Yes. I tried the code myself in Studio:

Worked like a charm.

Oh, ignore the background. This is a testing site for my scripts.

3 Likes

I’m fairly sure now that it’s because your character’s model hasnt fully loaded yet. For whatever reason, R6 characters don’t get created with all appearance stuff loaded whereas R15 characters do. Operatik’s test ran OK since they were using R15 while yours didn’t since you were using R6.

Run the following on top of the script:

local LocalPlayer = game.Players.LocalPlayer
if not LocalPlayer:HasAppearanceLoaded() then
    LocalPlayer.CharacterAppearanceLoaded:Wait()
end
5 Likes

I appreciate the help everyone has gave me, thanks.

1 Like

i need help

im basically trying to make a build tool that clones parts with children from the rep.storage and puts it where i click.

my children gets cloned in a part which works fine but the parent is cloned where I clicked and the children are cloned to their original position