MZ Transformation Troubles!

So I am having trouble setting up a transformation for my characters. It works for all but one character. The character who at the start of the game the player decides what they look like. I tried to make the transformation end event reference a variable that was modified at the start of the game in order to swap out the images based on what was chosen at the start. My code looks like this

<JS On Add State>
if (user.isActor()) {
user._prevCharName ??= user._characterName;
user._prevCharIndex ??= user._characterIndex;
user._prevFaceName ??= user._faceName;
user._prevFaceIndex ??= user._faceIndex;
user._prevBattlerName ??= user._battlerName;
const charName = "Animals";
const charIndex = 2;
const faceName = "Animals";
const faceIndex = 2;
const battlerName = "Wolf";
user.setCharacterImage(charName, charIndex);
user.setFaceImage(faceName, faceIndex);
user.setBattlerImage(battlerName);
user.refresh();
}
</JS On Add State>

<JS On Erase State>
const charName = user._prevCharName;
const charIndex = user._prevCharIndex;
const faceName = user._prevFaceName;
const faceIndex = user._prevFaceIndex;
const battlerName = user._prevBattlerName;
user.setCharacterImage(charName, charIndex);
user.setFaceImage(faceName, faceIndex);
user.setBattlerImage(battlerName);
delete user._prevCharacterName;
delete user._prevCharacterIndex;
delete user._prevFaceName;
delete user._prevFaceIndex;
delete user._prevBattlerName;
user.refresh();
if($gameVariables.value(7) = 1) {
user.setCharacterImage(Actor1, 5);
user.setFaceImage(Actor1, 5);
user.setBattlerImage(Actor1_5);
user.refresh();
}
else if ($gameVariables.value(7) = 2) {
user.setCharacterImage(Actor2, 7);
user.setFaceImage(Actor2, 7);
user.setBattlerImage(Actor2_7);
user.refresh();
}
else if($gameVariables.value(7) = 3) {
user.setCharacterImage(Actor3, 5);
user.setFaceImage(Actor3, 5);
user.setBattlerImage(Actor3_5);
user.refresh();
}
else if($gameVariables.value(7) = 4) {
user.setCharacterImage(Actor3, 6);
user.setFaceImage(Actor3, 6);
user.setBattlerImage(Actor3_6);
user.refresh();
}
else if($gameVariables.value(7) = 5) {
user.setCharacterImage(Female2, 1);
user.setFaceImage(Female2, 1);
user.setBattlerImage(Female2);
user.refresh();
}
else if($gameVariables.value(7) = 6) {
user.setCharacterImage(Actor2, 2);
user.setFaceImage(Actor2, 2);
user.setBattlerImage(Actor2_2);
user.refresh();
}


</JS On Erase State>

I'm guessing that the $gameVariable.value() is the wrong way to get the variable I need as right now when the transformation ends instead of using the images set in the if and else if statements it just loads the default images of the character which in this case for me is no image at all.
I could really use some help here.
So I am having trouble setting up a transformation
I am not sure how helpful this will be but kage desu has a plugin called anima x that swaps images and can layer them with character sprites. My question is the selectable character is it customizable? Because if it is just a different choice in actors then I d just create different sprite sheets for the transformation for each character. Then tie the sprite sheet change to common event attached to a skill/item transformation.
Moved to: Plugin Support
I'm guessing that the $gameVariable.value() is the wrong way to get the variable
So this should be entirely unnecessary.

The whole point of the original code is the first five lines store the current images etc. in variables on the actor.

The original code for the Erase State notetag would restore all of those stored parameters.

There should be no reason for you to go through checking a variable and setting the images again.
So I got some help from Trihan, My new Demigod of coding
This is what he told me
"You need to put quotes around the filenames because they're strings. Right now the code thinks you have variables called "Actor1" etc. and it's crashing because it can't find them.
You also need either == or === for your comparison.

if($gameVariables.value(7) = 1) won't work, because it's trying to set the return value of $gameVariables.value(7) to 1 (which it can't because the function only returns the value from _data, it can't set it"

So I made some changes and everything works now!

Original thread: https://forums.rpgmakerweb.com/threads/transformation-troubles.156352/