Player's Character Not Cloning?

Problems: (Player’s character is not cloning)

Error(s): image

Script: Located in ServerScriptService

game.Players.PlayerAdded:Connect(function(player) wait()
	player.Character:Clone().Parent = game.ReplicatedStorage
end)

Characters have archivable set to false, which means they cannot be cloned. Set it to true to do so.

1 Like

Do you know how I fix that???

Incorrect, you can still access characters. The problem is character is still a nil value, the server script executed the line of code too fast. Instead, OP should do this:

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char:Clone().Parent = game:GetService("ReplicatedStorage");
    end
end)

This makes it so that when the player’s character has finally loaded, “character” will no longer be nil and can be accessed by the server script.

Add a parenthesis ) on the other end as well, just forgot.

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char:Clone().Parent = game:GetService("ReplicatedStorage");
    end)
end)

The reasoning behind this is that it encloses the function. See (function(plr) is supposed to be (function(plr)), but end) encloses that.

Another error: image

You can’t straightly set the parent of :Clone(), you need to assign the char clone to a variable and then do it, I believe.

What I mean

local clonedChar = char:Clone()
clonedChar.Parent = game:GetService("ReplicatedStorage");

No, the ‘attempt to index nil with ‘Parent’’ error usually means that the latter before Parent, basically instancehere.Parent is nil, or not found. I’ve never had this issue before with cloning it like Instance:Clone().Parent = parenthere so I don’t really know what’s going on.

Oh my bad, as @KeysOfFate has said, you will need to set the Character to Archivable, like the following

Plr.Character.Archivable = true

image

It cannot access it in the first place, therefor it cannot change it

Can you show your updated code? you should set it to archivable before cloning it. And also in your code it would be

char.Archivable = true

That piece of code was just an example

game.Players.PlayerAdded:Connect(function(plr)
	plr.Character.Archivable = true
	plr.CharacterAdded:Connect(function(char)
		local clonedChar = char:Clone()
		clonedChar .Parent = game:GetService("ReplicatedStorage");
	end)
end)

Its showing nil, as you are doing

plr.Character.Archivable  = true

before the character is even added, you should move it inside it

There is a reason why this is happening. You’re trying to access the [color=lime]Archivable[/color] property of the player’s character before the CharacterAdded event, which means the player’s character is still nil, do this instead:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char.Archivable = true;
        local clonedChar = char:Clone()
		clonedChar .Parent = game:GetService("ReplicatedStorage");
	end)
end)
1 Like