How to store "EXP to Next Level" in a variable?

Currently, I have successfully created an event that allows a player to level up their party members using gold.
The player will activate the event, choose "Level up" from a choice box, then another choice box appears with
the names of the fours active party members asking to choose which to level up. After choosing one, the player
will be prompted to input a number using an input number event box, the number is then stored in a variable.
The number assigned to the variable is then deducted from the parties gold, and then applied to the character
that was selected.

However, I would much prefer to store the selected characters "EXP to next Lv" in a variable (rather than
have the player input a number of gold), than simply have it deduct that from the gold and Lv Up the Character.
However, I couldn't seem to devise a way to access the characters "EXP to next Lv" in order to store it in a
variable without the use of a plugin.

Does anyone know how I might be able to do this, without a plugin, maybe with a script command?
Try this in the script of a Control Variables command:

Code:
$gameActors.actor(id).nextRequiredExp()
@Shaz - Thank you so much for responding 😀 ! Im not sure if Im doing it right though. I thought I could store the actor ID in a variable (Which I think would be necessary, since there might be a different active character in any of the fours places of the active party.) but it tells me the actor is undefined after I choose one of the active party members (the only choice thats been defined so far is the first member of the party).

Spoiler
upload_2019-3-16_23-11-7.png

If the way Im doing it here is wrong, how to I get the actor ID if its possible the members of the party will be in different positions in the party at one time or another?

I hope Im not being too confusing with this. Thank you so much again 🙂 !
If you want to set the Actor's "EXP to Next" you can do it like this:

Code:
$gameVariables.setValue(1, $gameActors.actor(1).nextRequiredExp());

The first "1" is the Variable Number while the second "1" is the Actor Number.
Also where you typed "(Member1)" should just be the Actor's ID number.
You can't reference a variable by its name. It has to be the variable id. You also used $gameActor instead of $gameActors

$gameActors.actor($gameVariables.value(4)).nextRequiredExp()

However, if it's always the leader you're interested in, you can do this instead:

$gameParty.leader().nextRequiredExp()
@Shaz - 😀 THANK YOU! It worked! You wouldn't believe how many lines the first event I made was, just to do this! "If" branches out the butt...way too big to post here! This is so much more compact!

Spoiler
upload_2019-3-17_0-17-51.png

@BlackGoldSaw - Thank you so much for your response as well!

this thread can be closed 😀 !
To have a thread closed, just report your first post, and let the mods know the issue is resolved. That's the best/fastest way to make it happen 🙂

Actually, you can do it more easily than what you've got.

Code:
Show Choices: \p[1], \p[2], \p[3], \p[4]
When \p[1]
  Control Variables: #0004 Member = Actor ID of party member 1
When \p[2]
  Control Variables: #0004 Member = Actor ID of party member 2
When \p[3]
  Control Variables: #0004 Member = Actor ID of party member 3
When \p[4]
  Control Variables: #0004 Member = Actor ID of party member 4
End

Control Variables: #0001 SetSouls = $gameActors.actor($gameVariables.value(4)).nextRequiredExp()
If Gold < #0001 SetSouls
  Control Variables: #0001 SetSouls = Gold
End

Change Exp: (use variable 4 to choose the actor, and variable 1 to choose the amount)
Change Gold -= #0001 SetSouls
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/how-to-store-exp-to-next-level-in-a-variable.106899/