:Clone() not working in local script

I have absolutely no idea why this isn’t working. It functioned fine a while ago, however I changed a bit of code and now it doesn’t. It will run in a server script (with alterations to the player name of course), but not local.

local player = game.Players.LocalPlayer
local charac = workspace:WaitForChild(player.Name)
charac.Archivable = true


local clone = charac:Clone()
clone.Parent = workspace
clone.PrimaryPart = clone:WaitForChild("HumanoidRootPart")
clone:MoveTo(Vector3.new(19.581, 3.15, 25.422))

The error I receive is Infinite yield possible on Workspace.Player1:WaitForChild("HumanoidRootPart")'

the model of the player is copied, but it contains nothing

2 Likes

Instead use GetCharacterFromPlayer, It’s returning the player Object not the Actual Player’s Character.

1 Like

player.Character doesn’t work either, with the same errors

Oh, Do game.Workspace[player.Name]

Roblox players have Archivable set to false, which prevents cloning from working. do Character.Archivable = true then clone the player. (Didn’t notice you already do, lol)

Oh, Do game.Workspace[player.Name]

For the love of god, please don’t… the LocalPlayer.Character variable exists for a reason and any objects named the same as the player might get caught which has caused issues for me

1 Like

… do Character.Archivable = true then clone the player.

Above in the code snippet I’ve tried that, still nothing

Try Character = CharacterAdded:Wait(), maybe the character can’t load in before it’s cloned

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait()
character.Archivable = true


local clone = character:Clone()
clone.Parent = workspace
clone.PrimaryPart = clone:WaitForChild("HumanoidRootPart")
clone:MoveTo(Vector3.new(19.581, 3.15, 25.422))

even with this, I recieve errors that indicate the character is nil or has no descendants.
all other scripts but the local script are disabled

trying the code as a startercharacter localscript seems to “work”, though it has missing cosmetics
you’ll have to wait for the appearance to load in, and if it’s not that i am out of ideas

local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
print('player exists')


local function playerAdded(player)
	player.CharacterAppearanceLoaded:Connect(function(character)
		print('loaded')
		character.Archivable = true


		local clone = character:Clone()
		clone.Parent = workspace
		clone.PrimaryPart = clone:WaitForChild("HumanoidRootPart")
		clone:MoveTo(Vector3.new(19.581, 3.15, 25.422))
		print('clone moved')
	end)
end

Players.PlayerAdded:Connect(playerAdded)
print('eof')

even when placed into StarterCharacterScripts, loaded isn’t printed

I used this source code in the studio and it clones the model of a player correctly:

local player = game.Players.LocalPlayer
local charac = workspace:WaitForChild(player.Name)
charac.Archivable = true

local clone = charac:Clone()
if not clone:FindFirstChild("HumanoidRootPart") then
	repeat
	    charac = workspace:FindFirstChild(player.Name)
		clone = charac:Clone()
		wait(0.1)
	until clone:FindFirstChild("HumanoidRootPart")
end
clone.Parent = workspace
clone.PrimaryPart = clone:FindFirstChild("HumanoidRootPart")
clone:MoveTo(Vector3.new(19.581, 3.15, 25.422))
1 Like

that seems to work, however it doesn’t clone accessories and clothing

It really does depend on how fast internet and computer you have since the studio might miss look some things. I tested my script and it does fully clone my character to the workspace. WaitForChild() has a second parameter that you can use for a timeout to wait even more time for specific things, this most of the time fix the problems as you might have.

image

1 Like

I restarted my computer and it worked. maybe some ram issue that got flushed

1 Like