Help to set the camera subject to a custom character humanoid

I want to fix an issue with my script.

The problem is that I’ve made a team character script that depending on the team you pick a character but the camerasubject is set on the default character humanoid.

This is the code I made and try to fix.


game.Players.PlayerAdded:Connect(function(player)

	player.CharacterAdded:Connect(function(character)

		if player.TeamColor == Survivor then

			local newChar = characters.Guardian:Clone()
			newChar.Name = player.Name

			local humanoid = newChar:FindFirstChild("Humanoid")
			if humanoid then
				game.Workspace.Camera.CameraSubject = humanoid
			else
				warn("Humanoid not found in character")
			end

			newChar.Parent = workspace
			player.Character = newChar


		elseif player.TeamColor == Infected then

			local newChar = characters.Monster:Clone()
			newChar.Name = player.Name

			newChar.Parent = workspace
			player.Character = newChar

			local humanoid = newChar:FindFirstChild("Humanoid")
			if humanoid then
				game.Workspace.Camera.CameraSubject = humanoid
			else
				warn("Humanoid not found in character")
			end

		end
	end)
end)

The Issue:

What variable is player.TeamColor? maybe its the text or name of that variable you need to check? also use wait for child so that the characters load in fully before you change cameras.