I'm no expert, but I've learned how to work on and live with ES. Most ES problems can be resolved through common maintenance.
Start with a good strong, fully charged battery in the bike... this is very important. You also need a good wiring harness on the bike that hasn't been hacked on, spliced up or otherwise compromised. Replace either of those before continuing if they are not in excellent condition, else you're wasting your time.
Clean all of the cables and grounds on battery, motor and frame. Take the fenders off and unplug every harness connector pair on the bike and check for dirt/corrosion in them and clean & dielectric grease each one to keep water out of them.
Then take the shift motor and gears out and clean everything up. The old grease Honda used in those gets hard and dries out over time. Those gears (and each support bearing) will need fresh grease and care taken to put it back together correctly and watertight.
Don't throw money at it buying parts you don't need. You can get a service manual for your Foreman HERE
to aid in your maintenance chores and to insure its put back together right. There is also a decent troubleshooting flow chart in there if you find that a thorough maintenance session doesn't help. Let us know how it goes... we will gladly help you in any way we can.
Welcome to the forums!