How do i fix this character disguiser?

So im making a script where when you click on another character, it does not clone the accesories, only the shirt and pants AND body color,

heres the script:

local character = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()

local function Change(target, state)
	local children = target:GetChildren()
	for i = 1, #character:GetChildren() do
		local part = children[i]
		if part ~= nil then
			if part:IsA("Accessory") or part:IsA("BodyColors") or part:IsA("Clothing") then
				if state == "destroy" then
					part:Destroy()
				else
					local clone = part:Clone()
					clone.Parent = character
				end
			end
		end
	end
end

mouse.Button1Down:Connect(function()
	if mouse.Target ~= nil then
		local humanoid = mouse.Target.Parent:FindFirstChild("Humanoid")
		if humanoid then
			Change(character, "destroy")
			wait()
			Change(mouse.Target.Parent, "Clone")
		end
	end
end)

2 Likes

It’s not possible to get accessories from :IsA("Accessory"), but you can retrieve them by using Humanoid:GetAccessories(). You can use Humanoid:AddAccessory() to implement it into their character model.

:IsA("Accessory") is working, just gotta define it better.

local char = plr.Character
	local shirt,pants= nil,nil

	if char:FindFirstChildOfClass("Shirt") then
		shirt=char:FindFirstChildOfClass("Shirt")
	else
		shirt = Instance.new("Shirt",char)
	end 
	if char:FindFirstChildOfClass("Pants") then
		pants = char:FindFirstChildOfClass("Pants") 
	else
		pants = Instance.new("Pants",char)
	end

	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Accessory") then
			if v.Parent ~= nil then
				v:Destroy()
			end
		end
		
	end

	if pants ~= nil and shirt~= nil then
		pants.PantsTemplate = uniformset.Pants.PantsTemplate
		shirt.ShirtTemplate = uniformset.Shirt.ShirtTemplate
	end
	
	
	for i,v in pairs(uniformset:GetChildren()) do
		if v:IsA("Accessory") then
			local a = v:Clone()
			a.Parent = workspace
			char.Humanoid:AddAccessory(a)
		end
	end

This is something I made before.