Hi mquattlebaum, welcome to ATV Honda!
DTC 6 generally indicates one of three possibilities. Either the battery voltage supplying the shift ECU is low, there is a poor ground somewhere, or the ECU have failed. Running the ATV without a battery in it or running with a bad battery in it can cause a code 6 and/or cause the ECU to fry. So first make sure that the battery is in good condition and is fully charged. Make sure that the regulator/rectifier is charging the battery at the proper voltage too. Also poor/dirty/corroded/wet electrical connectors can lead to ECU problems, as can a chewed up or hacked up/spliced wiring harness or high friction/drag in mechanical electric shift components. Refer to the factory service manual for the charging system output spec, linked on our site from here.
If the battery is in good condition and fully charged, begin by taking both fenders off, disconnect every electrical connector on the ATV and clean the contacts with an electrical contact cleaning spray. Look closely for corrosion inside connectors as you work. After cleaning each connector pair apply dielectric grease generously inside them before snapping them back together. Remove the negative battery cable ground bolts from the motor case and the frame and shine those connections up too. All grounds must be clean and tight. Dielectric grease them to prevent them from corroding.
You will need to insure that every electrical part is a Genuine Honda part as well. If you have any china knockoffs on your Foreman you'll never fix it.
Let us know what you find... here is a guide for ES system prep you should follow after the code 6 issue is fixed.