Trouble with Cloning a Player

Hi, I need help with trying to clone a player, without it erroring for some reason.

I keep on getting this error however
image

from this code

wait(30)
print("Start")
local part = game.Workspace.sonicfoo3
local newpart = part:Clone()
newpart.Name = "Hi"

newpart.Parent = workspace
print(newpart.Parent.Name)

I have looked for solutions on the dev hub but I can’t find any solutions to solve my problem.
I have tried cloning a normal part and it seems to work from the same code.
I have also made sure the player loads in by the time the code runs

Any help would be greatly appreciated :grinning:

It seems like “part” is simply equal to nil meaning the game perhaps couldn’t find any “sonicfoo3” in the workspace, most likely because it takes time for the game to load a character so you can’t use it instantly. Try this instead, this will wait until the character is in the game for real.

local part = game.Workspace:WaitForChild("sonicfoo3")

make sure the player character archivable is false before cloning

Thank you for this, however its archivable is true, not archivable is false, for cloning, but I wouldn’t have realized without your comment

Hi, that would be a much better solution to what I did but I was walking around and my player was working because of the 30 second wait for it to load in, sorry for not mentioning that clearly, and thanks for your help