Swapping accesories between NPCs

I am working on a code that clones an npc, puts accesories/clothing from another npc in it and parents it to a ViewportFrame, the clothes work however the accesories don’t.
Code:

	Model = Model:Clone()
	local Pose = Poses[math.random(#Poses)]:Clone()
	
	for _,accesory in pairs(Model:GetChildren()) do
		if accesory:IsA("Accessory") or accesory:IsA("Shirt") or accesory:IsA("Pants") then
			accesory.Parent = Pose
		end
	end
	
	Model.Head:FindFirstChildOfClass("Decal").Parent = Pose.Head
	
	Pose.Parent = Showcase.Showcase.ViewportFrame

NOTE: this is not the full code.

Result:
Screenshot_2218

What it looks like with hats:
Screenshot_2219

No errors show up in output.

2 Likes

make sure the hats are not anchored and if it still occurs, try parenting the hats to workspace and then to the npc, i’ve had to do that with my game alot

3 Likes

if accessory then
humanoid:AddAccessory(accessory)

3 Likes

Didn’t work, the accessories aren’t anchored either.

1 Like

Worked the same as the code in the topic (Didn’t work), also just noticed the hats are misplaced as when I opened output the ViewportFrame got wider and found this:
Screenshot_2220

Not sure what’s wrong-

1 Like

Does the character have an Humanoid and is it an Model?

1 Like

Yes, it’s also stored in a folder in ReplicatedStorage
Screenshot_2221

1 Like

Found some info:

  • It’s not the script causing problems it’s the welds.

My theory is that it’s the WorldPosition property on the welds causing this but I still have no fix.

Uhh, still having this problem… I’ve tried out anything I can think of and still no solution, for now I’ll just replace the pose with the npc standing still until I find one :confused: .

Fixed, turns out I had to first parent everything to the workspace then do the swapping. I guess this is what @Donimicc said but I didn’t really get the hint.

1 Like