When you post code, please use the CODE tags (the </> in the edit bar).
It keeps your lines, indentations, and braces working correctly.
const classid = $gameActors.actor(1)._multiclasses[1];
This does not match the line of code Trihan gave you. The whole point is that you need to be referencing a number. That number is the ID of the class you're trying to level up.
You can leave it as a typed number, the way NaososX showed you, or you can put it in a variable so you can copy and paste this code for different classes and just change one number. But you didn't copy and paste what Trihan said to do, so you're not setting the variable to a number - you're setting it to a CLASS object.
for (let i = $gameActors.actor(1)._classLevel[classid]; i < $gameActors.actor(1)._classLevel[classid] + 1; i++) {
I know it was in the example that NaososX gave you, but as he said that was just an example for you to work off of. In your specific case, there's no point in using a for loop. You're not doing something to multiple classes, you're doing it one time. There's no reason to have several lines of code to make a loop that runs once.
All you
actually need to do for what you're asking is this:
Code:
let classId = 2;
$gameActors.actor(1)._exp[$gameActors.actor(1).getMulticlassAtTier(classId)?.id]=$gameActors.actor(1).expForClassLevel(classId, $gameActors.actor(1)._classLevel[classId]);
That will level up class 2 one time. If you want to level up a different class, change the number after
let classId
If you want it slightly more readable:
Code:
let classId = 2;
let actor = $gameActors.actor(1);
actor._exp[actor.getMulticlassAtTier(classId)?.id]=actor.expForClassLevel(classId, actor._classLevel[classId]);
That would also allow you to change the targeting on the fly, if you make your item usable on any given actor, you can use the event command to get the targeted actor ID into a variable first.
In that case, you'd change the second line to say
let actor = $gameActors.actor($gameVariables.value(X)); where X is the ID of the variable.