Character Appearance not Loading onto Rig?

Hey! Thanks for reading! I was working on an announcement menu for a game, and I want the character who sent the message’s current appearance to load onto a ViewportFrame. For some reason, the assets load onto the rig, and partially works. :slightly_frowning_face:

function loadAppearance(viewportCharacter, character)
	
	local items = {}
	
	for _, obj: Instance in pairs(character:GetDescendants()) do
		if obj:IsA("Shirt") or obj:IsA("Pants") or obj:IsA("ShirtGraphic") or obj:IsA("Accessory") or obj:IsA("BodyColors") then
			table.insert(items, obj:Clone())
		end
		
		if obj:IsA("Decal") and obj.Name == "face" then
			local head = viewportCharacter:FindFirstChild("Head")
			if head then
				local face = head:FindFirstChild("face") or head:FindFirstChild("Face")
				if face then
					face.Texture = obj.Texture
				end
			end
		end
	end
	
	for _, item in pairs(items) do
		item.Parent = viewportCharacter
	end
	
	viewportCharacter.Head.Mesh.Scale = character.Head.Mesh.Scale or Vector3.new(1, 1, 1)

	if character.Head.Mesh.MeshType ~= Enum.MeshType.FileMesh then
		viewportCharacter.Head.Mesh.MeshType = character.Head.Mesh.MeshType
	else
		viewportCharacter.Head.Mesh.MeshId = character.Head.Mesh.MeshId
	end
end

function loadCharacter(character)
	local viewportCharacter = assets:WaitForChild("ViewportCharacter"):Clone()
	viewportCharacter.Name = "ViewportCharacter"
	viewportCharacter.Parent = workspace
	viewportCharacter:PivotTo(characterPosition)
	loadAppearance(viewportCharacter, character)
	viewportCharacter.PrimaryPart.Anchored = true
	viewportCharacter.Parent = background:WaitForChild("Icon")
	return viewportCharacter
end

When I mean partially, I mean the clothing loads onto the rig, but not the acessories. The acessories do exist on the ViewportFrame’s rig, they’re just for some reason still on my character. Thanks for reading! :smile:

The accessories probably have a property that defines what they’re attached to, probably an attachment.

An easier way to create an avatar based on the character would be to get the character’s HumanoidDescription (which is stored under the character or their Humanoid, I forget which one). Then, you can just call Players:CreateHumanoidModelFromDescription with the description and rig type to get a rig that looks just like the character.

1 Like

Same issue happens. Not sure why, but I think it has to do with the attachment that was defined (Just like you mentioned earlier.) Still thanks for the suggestion, it gets me closer to the issue! :smiley:

1 Like

Did you make sure to parent the rig to the Viewport frame?

Is the problem still that the attachments are appearing in the workspace? The function should create a brand new rig that has no context of the character model, since it’s just created from the Humanoid Description’s info.

It’s like the acessories are parented to the rig in the Viewport frame, but the attachments still make it stuck to my character. Thanks for your effort by the way. :+1:

Update: I just cloned the character and deleted the animate script, which made it work fine. It’s definitely not the perfect solution, but it’s the best I have at the moment.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.