local hats = 0
for i,v in pairs(HatsFold:GetChildren()) do
hats = hats + 1
local AssetId = v.ID.Value
local ClonedButton = script.Parent.Faces.Template:Clone()
ClonedButton.Visible = true
ClonedButton.Name = "Face"..hats
ClonedButton.Image = "https://www.roblox.com/asset-thumbnail/image?assetId="..AssetId.."&width=420&height=420&format=png"
ClonedButton.Parent = script.Parent.Hats
ClonedButton.MouseButton1Click:Connect(function()
local Hat = v:Clone()
Hat.Parent = game.Workspace.JoinDummy
end)
end
When ClonedButton is clicked I want it to put the hat (v in our case) onto the NPC. Luckily it clones the hat into the character, but it’s not in position.
you are going to need to weld the hats to the NPC the method i would use to do this is to get each of your hats and Weld a “weld part” to them.
so get a dummy and a part.
name the part “WeldPart” and the dummy “WeldPartDummy” type this into Command Bar: game.Workspace.WeldPart.CFrame = game.Workspace.WeldPartDummy.Head.CFrame
this will position the part perfectly in the head
the Put you Hat Above the Head
Now weld the “WeldPart” to the hat and group them together
when the “ClonedButton” is clicked position the weld part to the head of the NPC and weld the WeldPart to the Head of the NPC this will atoumatically put the hat in the right position and keep it attached. if you have any questions or didnt understand anything feel free to ask.