I’m trying to build an in-game store/avatar customizer.
I’d like to clone my player’s current character into a ViewportFrame.
However, cloning a player’s character seems to fail silently.
If I create a new doc in Studio, join and type this code into the command bar:
local p = game.Players.Shedletsky.Character:Clone() p.Parent = game.Workspace
It throws because p is nil.
I don’t want to load a character from the website using
CreateHumanoidModelFromUserId, because I am using custom characters. I want to clone my guy like I can do in Studio with a copy/paste.
I don’t understand why the character model is special.
I went the long way around and did this, but it breaks character animation and I have no idea why:
function charCopy(player) local c = player.Character or player.CharacterAdded:Wait() print("character loaded locally") local k = c:GetChildren() local result = Instance.new("Model") for i = 1,#k do k[i].Archivable = true local t = k[i]:Clone() t.Parent = result end result.Name = player.Name return result end local char = charCopy(game.Players.LocalPlayer)