Character not cloning, returning nil instead

things you need to know:

  • in a local script
  • character doesnt return nil but clone does

Code example

local player = game.Players.LocalPlayer
local char = player.Character
if not char then
	char = player.CharacterAdded:Wait()
end

local plrClone = char:Clone()
plrClone.Parent = workspace --errors out on this line.
plrClone.Name = "PlrClone"

other than that, the title implies itself. ask any questions you may have, please.

2 Likes

i’ve modified it a bit, try this:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()


local plrClone = char:Clone()
plrClone.Parent = game.Workspace
plrClone.Name = "PlrClone"

What’re you trying to achieve? This seems kind of impractical. Maybe try switching it up to be:

local char = player.Character or player.CharacterAdded:Wait()

That’s just what I do when I get the character from the client, plus is lowers the amount of useless stuff in the script

1 Like

not actually parenting it to the workspace, using it in a viewport frame, but i used workspace as an example to save complexity.

2 Likes

Ah I see. You should probably use their character thumbnail for those types of things. Or, if you’re trying to make a viewport frame for their character moving, there is a tutorial for that.

local image = game.Players:GetUserThumbnailAsync(v.UserId,Enum.ThumbnailType.AvatarBust,Enum.ThumbnailSize.Size100x100)
viewport.Image = image
1 Like

i figured that i would just have a blank rig and simply load the character appearance onto the rig instead. thanks for the help, however!

2 Likes

You just needed to add char.Archivable = true before attempting to clone it.
https://developer.roblox.com/en-us/api-reference/property/Instance/Archivable

3 Likes

why would you need to do that when all you need to do is set the Archivable = true, like what @Forummer said.

because that removed everything within the model lol

You need to wait for the player’s character’s appearance to load before attempting to clone it.

if not Player:HasAppearanceLoaded() then Player.CharacterAppearanceLoaded:Wait() end