If you want to try getting the bike in some sort of functional status, you could service the carbs, put in a battery, synch the carburetors, and see if that would get it running. Don't forget to examine the gas tank! If you do NOT see shiny metal in-there, you'll need to pull the tank and clean it and possibly coat it. There are many threads on all of this: carburetors should be ultrasonically cleaned for best results, the gas tank, if it's rusty, you can use cleaning vinegar to rid it of rust, coating with a known product is optional. A new battery, and synching the carburetors, and you should be able to get the engine running. Then you can see what is happening with the 4th gear issue, replacing the shift drum star mechanism isn't hard to do if you have the tools. Removal of the clutch basket is required.
All that said, even if 4th gear is not the shift selector star mechanism, and requires case-splitting, an operational bike which runs is worth more than one which doesn't. If you have to pay someone to do the carburetors, and they need a lot of parts, that could easily reach $1,000 parts & labor. They may not cost that much, but most people who are working with these on a regular basis would rather replace suspect parts than assume, "they're ok."
A new fuel tank is $407 and you would need to spend probably $300 in labor to pull the tank, clean it, and re-install it. For another $107 I'd get a new one, if the old one is badly rusted.
Fuel Tank Comp
1FK-24110-10-33
Retail Price: $527.99
Your Price: $406.55
https://www.ronayers.com/oemparts/a/yam/50045c14f8700209bc794305/fuel-tank
You can see how it would be easy to spend $2,000 trying to make your bike operational. There are some workarounds. You could use an auxiliary gas tank if yours is rusted badly. Your carburetors are something that will need removal disassembly, some new parts, and reassembly/reinstallation, and you could use an 'outside the bike' battery just to see if the cleaned carburetors and an auxiliary gas tank would at least make it start and the engine run. Then you could buy a battery and see what's up with 4th gear.
I suspect you may not have the incentive nor the $ to invest in the bike, where you spend $1,000 trying to make it run, but it doesn't, That's what makes it a $500 bike. It's better to sell it, and say, 'good-bye' than to think "I'm gonna part it out," and end up with most of a bike and a few pieces gone.