With this line: if Input.trigger?(Input::LEFT) && @partyindex>0
You need to get rid of the "&& @partyindex>0" bit, since this is causing it to ignore a left press if we're on the first pokemon. Then check the pbGoToPrevious script and where it manipulates @partyindex you can set it to go wherever you need.
Similar with this line: if Input.trigger?(Input::RIGHT) && @partyindex<@party.length-1
And you'll need to edit pbGoToNext for that one.
However this used to cause problems with pokemon cries, so unless you need to I wouldn't bother :/