Team Morph doesn't work, when spawning as the team

After getting into the Medical team, the Hazmat suit should be worn, but it does not and I am not really sure why, I would be happy if someone could help me with that.

game.Players.PlayerAdded:Connect(function(player)
		if player.Team == game.Teams["Medical Department"] then
			if player:GetRankInGroup(8866378) >= 8 then

				local hazDep = game.ServerStorage.Chars["MD HR"]

				for i, accessory in ipairs(player.Character:GetChildren()) do
					if accessory:IsA("Accessory")
						or accessory:IsA("Shirt") 
						or accessory:IsA("Pants")
					then accessory:Destroy()
					end
				end

				for i, hazSuit in ipairs(hazDep:GetChildren()) do
					local suit = 	hazSuit:Clone()
					suit.Parent = player.Character
					print(hazSuit.Name)
				end
			end	
		end
	end)

Attempt changing if player.Team == game.Teams['Medical Department'] then to if player.Team.Name == 'Medical Department' then

Other than that if the morph is accessories use AddAccessory than parenting it to the character, I have a module that does that for you. Alternatively check if the hazmat suit is welded properly so It’s not that the accessory is applied but because of broken welds it falls through the world.

It still doesn’t work.

So basically you had to click on an object to wear the hazmat suit, but I changed it to be worn when they spawn as an MD.

This was the script, the morph worked. If the welding wouldn’t work, then I should still get the clothes, but I am not even getting the clothes.

local click = script.Parent.ClickDetector
local hazDep = game.ServerStorage.Chars.hazDep

click.MouseClick:Connect(function(player)
	if not player.Character:FindFirstChild("pDebounce") then
		
		for i, accessory in ipairs(player.Character:GetChildren()) do
		if accessory:IsA("Accessory")
		or accessory:IsA("Shirt") 
		or accessory:IsA("Pants")
		then accessory:Destroy()
		end
		end
		
	
	for i, hazSuit in ipairs(hazDep:GetChildren()) do
	local suit = 	hazSuit:Clone()
	suit.Parent = player.Character
	print(hazSuit.Name)
	end
	local gun = game.ServerStorage.SpecialTools["Jet Injector"]:Clone()
	gun.Parent = player.Backpack
	local pDebounce = Instance.new("StringValue")
	pDebounce.Parent = player.Character
	pDebounce.Name = "pDebounce"
	
	
	end	
end)

Try

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		player.CharacterAdded:Wait()
		
		if player.Team == game.Teams["Medical Department"] then
			if player:GetRankInGroup(8866378) >= 8 then

				local hazDep = game.ServerStorage.Chars["MD HR"]

				for i, accessory in ipairs(player.Character:GetChildren()) do
					if accessory:IsA("Accessory")
						or accessory:IsA("Shirt") 
						or accessory:IsA("Pants")
					then accessory:Destroy()
					end
				end

				for i, hazSuit in ipairs(hazDep:GetChildren()) do
					local suit = 	hazSuit:Clone()
					suit.Parent = player.Character
					print(hazSuit.Name)
				end
			end	
		end
	end)
end)

No. it’s still not working, I also can’t find anything in the output.

Nevermind, I have done it in an other way, thank you for trying to help me!