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.
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!