function onPlayerRespawned(s)local Z=game.Players:findFirstChild(s.Name)if Z~=nil then local A=Z.TeamColor local M=game.Lighting.Hats:GetChildren()local H=s.Character:GetChildren()for Z=1,#M,1 do local H=Instance.new("\072\097\116")if M[Z].Name=="\084\111\114\115\111"then H.AttachmentPos=Vector3.new(0,8,0)end local h=M[Z]:clone()wait(1)h.Parent=H h.BrickColor=A h.Name="\072\097\110\100\108\101"H.Parent=s.Character end wait(6)for s=1,#H,1 do print(H[s].Name)if H[s]:FindFirstChild("\072\097\110\100\108\101")~=nil then H[s]:remove()print("\114\101\109\111\118\101\100")end end end end function onPlayerEntered(s)s.Changed:connect(function(Z)if Z=="\067\104\097\114\097\099\116\101\114"then onPlayerRespawned(s)end end)end game.Players.ChildAdded:connect(onPlayerEntered)


function onPlayerRespawned(newPlayer)

local Team = game.Players:findFirstChild(newPlayer.Name)

	if Team ~= nil then

		local TeamColor = Team.TeamColor

		local c = game.Lighting.Hats:GetChildren()

		local p = newPlayer.Character:GetChildren()

		for i = 1, #c do

			local a = Instance.new("Hat")


			if c[i].Name == "Torso" then

				a.AttachmentPos = Vector3.new(0, 8, 0)

			end

                




			local clone = c[i]:clone()

			wait(1)

			clone.Parent = a--Delete team color and the -- next to newplayer and the spaces to make the armor spawn the color of the Players Torso

			clone.BrickColor = TeamColor --newPlayer.Character.Torso.BrickColor

			clone.Name = "Handle"

			a.Parent = newPlayer.Character

			

					

		end 

		wait(6)

		for i = 1, #p do

			print(p[i].Name) 

			if p[i]:FindFirstChild("Handle") ~= nil then

				p[i]:remove()

				print("removed")

			end

		end

	end

end



function onPlayerEntered(newPlayer) 

	newPlayer.Changed:connect(function(property) 

		if (property == "Character") then 

			onPlayerRespawned(newPlayer) 

		end 

	end) 

end 





game.Players.ChildAdded:connect(onPlayerEntered)
