function onClicked(A)print(A.Name)print(A.Parent.Name)if A.Character:findFirstChild("\072\117\109\097\110\111\105\100")~=nil and A.Character:findFirstChild("\067\104\101\115\116")==nil then local W=script.Parent.Parent.Chest:clone()W.Parent=A.Character local X=W:GetChildren()for Z=1,#X,1 do if X[Z].className=="\080\097\114\116"or X[Z].className=="\085\110\105\111\110\079\112\101\114\097\116\105\111\110"or X[Z].className=="\077\101\115\104\080\097\114\116"then local A=Instance.new("\087\101\108\100")A.Part0=W.Middle A.Part1=X[Z]local p=CFrame.new(W.Middle.Position)local u=W.Middle.CFrame:inverse()*p local L=X[Z].CFrame:inverse()*p A.C0=u A.C1=L A.Parent=W.Middle end local p=Instance.new("\087\101\108\100")p.Part0=A.Character.Torso p.Part1=W.Middle p.C0=CFrame.new(0,0,0)p.Parent=p.Part0 end local Z=W:GetChildren()for A=1,#Z,1 do if Z[A].className=="\080\097\114\116"or X[A].className=="\085\110\105\111\110\079\112\101\114\097\116\105\111\110"or X[A].className=="\077\101\115\104\080\097\114\116"then Z[A].Anchored=false Z[A].CanCollide=false end end end if A.Character:findFirstChild("\072\117\109\097\110\111\105\100")~=nil and A.Character:findFirstChild("\072\101\097\100\103\101\097\114")==nil then local W=script.Parent.Parent.Headgear:clone()W.Parent=A.Character local X=W:GetChildren()for Z=1,#X,1 do if X[Z].className=="\080\097\114\116"or X[Z].className=="\085\110\105\111\110\079\112\101\114\097\116\105\111\110"or X[Z].className=="\077\101\115\104\080\097\114\116"then local A=Instance.new("\087\101\108\100")A.Part0=W.Middle A.Part1=X[Z]local p=CFrame.new(W.Middle.Position)local u=W.Middle.CFrame:inverse()*p local L=X[Z].CFrame:inverse()*p A.C0=u A.C1=L A.Parent=W.Middle end local p=Instance.new("\087\101\108\100")p.Part0=A.Parent.Head p.Part1=W.Middle p.C0=CFrame.new(0,0,0)p.Parent=p.Part0 end local Z=W:GetChildren()for A=1,#Z,1 do if Z[A].className=="\080\097\114\116"or X[A].className=="\085\110\105\111\110\079\112\101\114\097\116\105\111\110"or X[A].className=="\077\101\115\104\080\097\114\116"then Z[A].Anchored=false Z[A].CanCollide=false end end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)


function onClicked(hit)
    print(hit.Name)
    print(hit.Parent.Name)
	if hit.Character:findFirstChild("Humanoid") ~= nil and hit.Character:findFirstChild("Chest") == nil then
		local g = script.Parent.Parent.Chest:clone()
		g.Parent = hit.Character
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].className == "Part" or C[i].className == "UnionOperation" or  C[i].className == "MeshPart" then
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
				local Y = Instance.new("Weld")
				Y.Part0 = hit.Character.Torso
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			if h[i].className == "Part" or C[i].className == "UnionOperation"  or C[i].className == "MeshPart" then
				h[i].Anchored = false
				h[i].CanCollide = false
			end
		end
		
	end
	
	if hit.Character:findFirstChild("Humanoid") ~= nil and hit.Character:findFirstChild("Headgear") == nil then
		local g = script.Parent.Parent.Headgear:clone()
		g.Parent = hit.Character
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].className == "Part" or C[i].className == "UnionOperation" or  C[i].className == "MeshPart" then
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
				local Y = Instance.new("Weld")
				Y.Part0 = hit.Parent.Head
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			if h[i].className == "Part" or C[i].className == "UnionOperation" or  C[i].className == "MeshPart" then
				h[i].Anchored = false
				h[i].CanCollide = false
			end
		end
		
	end	
	
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
