Chances are you do not have enough throw on the shifting lever.
hoping that pic is actually YOUR engine it's easy to narrow in on the problem.
See the ratcheting arm (under the star gear), it does just as you'd assume.. rotate that star clock or counterclockwise.
(well the gear beneath the star.. the star is nothing but a detent for the roller below... nevermind)
if the pivot of said ratcheting arm(aka hook plate) is firm (on the top right of the pic you provided)
and that rivet isn't slopping around and it (the arm) does indeed happily snap back if you pull it down and let go again.
telling you that the tiny spring is firm enough as well
IT can NOT be the cause of your issue.
So we can move down the linkage... the main lever itself (down the aforementioned rivet that is)
it should be firm as well.. and if you move it by hand you should get the action of the ratchet going.
if you cannot, make sure it's not seized up at on of the endpoints (check for scratches in it's path to see if it's ever so slightly bent or such)
If you can... again it can no longer be the cause.
Make sure the torsion spring (sits on the same shaft and holds said main lever in it's neural position)
is in good condition and is actually bringing the lever back to it's center position.
clearing the shifting finger inside the window... (as the picture suggests)
Now.. the shifting finger is actuated by the shifting shaft with the shift lever.
(finally)
it's welded on.. but that doesn't mean it cannot come loose at all unfortunately..
so the last two things on this side are to check if
a) the finger is firmly and playlessly actuated by the shifting lever
and
b) the shifting lever itself has enough clearance that you can actually make the arm move all the way.
sometimes people readjust the lever so they can keep their foot resting on it more comfortably while riding..
and that can cause it to NOT have enough throw to properly shift...
sooo maybe you want to readjust it a tooth or two on the shaft if that helps.
If you read down to here and the issue has not been resolved..
I'm afraid we talk gear box issue..
So grab that star with you hand and check if if it's nicely fixed to the gearshaft.
difficult to explain, with a well fixed shaft you can feel the fork and the 'play' feels soft'ish;
if the coggear sits loose on the gearshaft you can feel its play before you get the fork into contactIf so,
you might need to replace its pins, to have a nice and tight connection again.
Said gearshaft can build lands over time, and the shifting fork could be worn out.
on a mildly worn gearbox you can temporarily resolve a locked gearbox, by just reengaging the clutch again,
usually the inertia of the engine rattles the fork free and you can shift with your next attempt declutching it.
If so, you might be able to adjust the clutch a bit, but usually it means you need a new shifting fork sooner or later.
(maybe a shifting shaft too... that'll be seen during inspecting the parts)
Another issue with about all motorcycle gearboxes is the clutch actuation itself..
clutch cables stretch and people don't readjust properly.. and sometimes that can cause misbehaviour..
resulting in a worn clutch up to a point where the clutch plates get bent and you cannot ever declutch properly again
(until the clutch plates are replaced)
But let's just hope you have fixed the issue one paragraph ago already
'sid