Hats don't attach properly to character in ViewportFrame

I’m trying to make a dialogue system. I want an icon on the right showing the NPC.
I did this by copying the face, colors and the hats onto a character in a ViewportFrame.
The problem is the hats. They won’t attach properly onto the ViewportFrame character.
I have no clue why or how to fix this.

This is the icon

This is the actual character

The hat does indeed get copied, but it stays in the exact same position of the actual character

This is a portion of the script, you dont need to know the full script, but if you want you can ask me for it in the comments.
Local Script:

person.Head.Face.Texture = npc.Head.Face.Texture
if npc:FindFirstChild("Body Colors") then
	npc["Body Colors"]:Clone().Parent = person
for _, accesories in pairs(npc:GetChildren()) do
	if accesories:IsA("Accessory") then
	    local hat = accesories:Clone()

I would greatly appreciate some help! Thanks!

Did you check the ClassName value? Alot of the time hats would be called “HatAccessory” instead of just “Accessory” for some reason

Might also have something to do with its currentcamera

The ClassName value is “Accessory”

Also if you’re cloning an entire accessory item and using :AddAccessory() it may not work, its usually used for mesh parts, have you tried using humanoid descriptions instead?

Try to put the parent of the Character to Workspace and wait(.01) then put it back to the viewport frame.

1 Like

Humanoid descriptions are much easier to use you can create one and set its HatAccessory to whatever the Model ID is… Heres an example

local NPC_Humanoid = person.Humanoid
local humDesc = NPC_Humanoid:GetAppliedDescription()

humDesc.HatAccessory = 123456789 --ID of your accessory model that you have uploaded

This appears to also not work.
Since I used a local script, and ApplyDescription() only works on the server I had to use a remote event. It also did not have the hat on.

Made the character look funny, but still didn’t get the hat.

I am currently experiencing this same issue.

Sorry for the SUPER late response, but I managed to fix it!
You have to apply the accessory in workspace before moving it to the ViewPort frame.
you can do this:

npc.Parent = workspace
-- you can add accessory here
npc.Parent = viewport
-- or you can add them here, it works for me.
1 Like