I'm trying to add custom accessories added to the player onced joined when in specific teams. The problem sometimes shows this error and the accessories don't show up. On line 22, I the part removes the players custom accessories then replaced with the the team accessories. So why doesn't it work? Thanks.

local ss = game:GetService("ServerStorage")

local function playerAdded(player)
	player.CharacterAdded:Connect(function(char)	
		
		local vest = nil
		local hat = nil
		local leg = nil
		
		if player.Team.Name == "Chief" then
			
			vest = ss.Uniforms.Chief:WaitForChild("Vest"):Clone()
			hat = ss.Uniforms.Chief:WaitForChild("Hat"):Clone()
			leg = ss.Uniforms.Chief:WaitForChild("Leg"):Clone()
			
         elseif player.Team.Name == "---" then
			vest = ss:WaitForChild("---"):Clone()
		end
		
		local hum = char:WaitForChild("Humanoid")
		
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("Accessory") then
				v:Destroy()
			end
		end
		
		wait()
						
		--[[hum:AddAccessory(vest)
		
		hum:AddAccessory(hat)
		
		hum:AddAccessory(leg)]]

hum:AddAccessory(vest, hat, leg)
		
	end)
end

game.Players.PlayerAdded:Connect(playerAdded)

1 comment

0

Edit: Sorry if the scripts a mess or its not the most best way/efficient, just typed what I knew.