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