---------------------------------------------------------------------------------------------l}o
------------------------------Blox370's Script-----------------------------------l}o
---------------------------------------------------------------------------------------------l}o


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)
