Apply layered clothing to NPC from client

So I have this GUI that gets items from the Roblox catalog and can spawn items onto the NPC. Thing is when I try with layered clothing it spawns in the area its meant to be, but doesn’t really conform to the NPCs body
Screenshot 2023-07-14 at 17.51.50

This is the code that connects the clothing to the NPC

if npcItem:IsA("Accessory") and npcItem.Handle:FindFirstChild("BodyFrontAttachment") then
	print("item is a front accessory")

	if npcItem:WaitForChild("Handle"):IsA("MeshPart") then
		npcItem:WaitForChild("Handle").Size = npc.Torso.Size
	end

	local frontConstraint1 = Instance.new("RigidConstraint", npcItem)

	frontConstraint1.Attachment0 = npcItem:WaitForChild("Handle"):FindFirstChild("BodyFrontAttachment")
	frontConstraint1.Attachment1 = npc.Torso.BodyFrontAttachment
end

For those wondering, the LocalScript this is inside of pretty much has that same code in a big elseif that goes through all attachment types and those items get spawned in from a RemoteEvent on the servers side.

1 Like

Did you set the Accessory onto the Character’s Parent?

Yes that happens in this server sided RemoteEvent

wearTakeoffEvent.OnServerEvent:Connect(function(player, ID, arg)	
	if arg == "wear" then
		local asset = insertService:LoadAsset(ID)
		local access = asset:GetChildren()[1]
		access.Parent = game.ReplicatedStorage.ItemStorage
		access.Name = ID
	end
end)

And then cloned in the LocalScript

local npcItem = game.ReplicatedStorage.ItemStorage:WaitForChild(ID.Value):Clone()
npcItem.Parent = npc

No, that is not what happens in the server-sided RemoteEvent. You set the parent to ItemStorage, then on the client, you move it over, which would not allow the layered clothing to format since it’s not there correctly (not on the actual localPlayer).

So I then just change the parent to be the NPC?

Yeah, whatever you are trying to put the outfit on.