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:
--<Viewmodel>--
person.Head.Face.Texture = npc.Head.Face.Texture
if npc:FindFirstChild("Body Colors") then
npc["Body Colors"]:Clone().Parent = person
end
for _, accesories in pairs(npc:GetChildren()) do
if accesories:IsA("Accessory") then
local hat = accesories:Clone()
person.Humanoid:AddAccessory(hat)
end
end
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?
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
NPC_Humanoid:ApplyDescription()
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.
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
wait(0.1)
npc.Parent = viewport
-- or you can add them here, it works for me.