Rotate actors within their party slots

Hey all. So using Ultra Hud Maker Pro I'm attempting to make a character select screen where the player can choose the actor in each party slot. I'm using the script call gameActors._[0] = $gameVariables.value(1), with the variable being set to an actor ID. It works up until the rotation gets back to the top, where I get an 'alreadyappeared' error. Is there anyway to do this without a plug-in? I'm looking at Himes Instance Actors but I'm not sure if duplicates would work. Any help would be appreciated!
JavaScript:
const partyTemp = Array.from($gameParty._actors);
for (const id in partyTemp) {
    $gameParty._actors[(parseInt(id) + 1) % $gameParty.size()] = partyTemp[id];
}

This will rotate every actor up 1 slot and wrap the one at the end around to the beginning.
Thanks for the reply. To clarify, I'd like to rotate just one slot at a time. For example if Reid is in slot one and Eliott in slot two, if I rotate Reids slot, I'd like Elliott, and the other slots, to remain where they are. My script call, along with some variable commands does this, until Reid comes back to the top, where I get the error.
So you just want to swap out a specific slot? Just do $gameParty._actors[id to swap out] = $gameVariables.value(1); then.
So you just want to swap out a specific slot? Just do $gameParty._actors[id to swap out] = $gameVariables.value(1); then.
That's exactly what I have been using. But as I said, it works until the rotation comes back around to the top. If it starts with Reid it will rotate through all the actors until it is time to come back to Reid, when I get an 'already appeared' error.
That's exactly what I have been using. But as I said, it works until the rotation comes back around to the top. If it starts with Reid it will rotate through all the actors until it is time to come back to Reid, when I get an 'already appeared' error.
Can I see your current code?
I'm not at my computer right now, but this is the jist of it. Since then, the only thing I added was a label and three conditional branches but they don't impact the issue.
Can I see your current code?


EDIT: Now that I'm looking at it, I'm wondering if the variable should be reset to 1 instead of 0.
I'm not at my computer right now, but this is the jist of it. Since then, the only thing I added was a label and three conditional branches but they don't impact the issue.



EDIT: Now that I'm looking at it, I'm wondering if the variable should be reset to 1 instead of 0.
Yep, I think that's the problem. Actor ID 0 is null.
Yep, I think that's the problem. Actor ID 0 is null.
That was exactly it! I guess this is solved.

Original thread: https://forums.rpgmakerweb.com/threads/rotate-actors-within-their-party-slots.155502/