Shirts and Pants not loading on ViewportFrame WorldModel

I’m making a large script, and part of it involves cloning the player’s avatar and putting it into a viewport frame for a GUI. It used to work, but now the shirts and pants for the avatar do not load.


image
I’m being commissioned to make it so I’d rather not leak the whole thing, but it clones the entire player and then updates the CFrame of each part to match the player (I’ve got an idea for later that will use it)

for i,v in pairs(character:GetChildren()) do
	newPart = v:Clone()
	newPart.Parent = Avatar
	if v:FindFirstChild("CFrame") ~= nil and v:FindFirstChild("Position") ~= nil then
		newPart.CFrame = v.CFrame
	end
	if v:FindFirstChild("Anchored") ~= nil then
		v.Anchored = true
	end
	if v.Name == "HumanoidRootPart" then
		newPart.Name = "HumanoidRootPart"
		newPart.Position = (offset)
	end
end

The script used to work flawlessly, loaded my clothes and hats and everything. I can’t tell if this is an API bug or if I’m doing something wrong. The shirts and pants are cloning into the WorldModel, I tested it using print() to make sure they were loading. I even tried loading the humanoid first, still didn’t work. I have yet to publish and test in game, but maybe it works in game but not in studio, I’ve had that happen a couple times.

Any help would be greatly appreciated, thanks!

I think you should just clone the player’s character into the frame, then import the CFrames so like:

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

char.Archivable = true --I believe default is false
local vpfmodel = char:Clone() -- clone it
vpfmodel.Parent = script.Parent -- not sure where the script is located so you should change the directory based on that

vpfmodel.PrimaryPart.Position = offset -- not sure why this is in parenthesis in your code

for _, item in pairs(vpfmodel:GetChildren()) do -- loop through cloned parts
    if item:IsA("BasePart") then -- detects if its a body part (Head, UpperTorso, RightHand etc.)
        item.Anchored = true -- anchors it
        item.CFrame = char[item.Name].CFrame -- set CFrame based on name
    end
end

Edit: If this is located on a server script you would have to get the player instead of the using LocalPlayer.