Set Variable to Actor Level Question

Hi,

My game lets you choose a character to play as, from about 20 characters. So my list of actors has about 20, and the player can choose one at the start of the game. You only play as 1 character.

I want to create a variable that will change to the player's level automatically each time he levels up.

The problem is, I don't know which character is gonna be the one selected by the player. So far all the examples of how to do this I found needed me to specify the exact actor I want to check for level and set the variable...

So...in other words...How do I make it set the variable to the level of the first character in the party? 

Thanks for any help!!!
I would suggest a different approach:


1 actor only.


Use Change Actor Graphics, Change Actor Name, Change Actor Class, based on selections by the player.


Then you only have 1 actor whose level (or equipment, or skills, or anything else) that you need to check.
Thanks...but I don't think that idea would work for me...or it would be way too complicated.

I need each character to have very different and unique skills, stats, etc...so changing everything for each choice is gonna be a lot of work...

I thought there would be something very easy for this? :\ it only requires to check the lvl of the party leader...
You set up the classes with all the equipment, skills, stats. So you would have as many classes as you need. The Change Actor Class, which you do right at the start, then gives all those skills/stats/equipment assigned to the class to the actor.


To get the party leader's level into a variable:

Control Variables: [001: Leader Level] = Script: $gameParty.leader().level()but then you would have to figure out how to set it up at the end of each battle.
Here are some plugins that you might find useful (use one or the other - not both):


Linked Variables (link a variable to '$gameParty.leader().level()')


Battle Result Switches (turn on the same switch for each battle outcome, then have a parallel processing common event conditioned by that switch, which will do the Control Variables shown above and then turn the switch off)
Hmm. thanks!..I tried using the script you wrote:

Started an event with: Control Variables: [001: Leader Level] = Script: $gameParty.leader().level()

Then a conditional branch with - If: Leader Level = 2

Show text: You're level 2!

I then chose a character which starts at level 2, and tested the game.

I'm gettting an immediate error msg: TypeError - number is not a function

help!
please give a screenshot of your event - I think you might have placed too much into the script section.


Shaz answer was a mix of event command and script command, and only the part with the $ goes into the script line of a control variable command, everything befor is event command.
Yes...I only put the $gameParty.leader().level() part into the script section.

What I wrote is how the final line looks in the event...

http://puu.sh/lMsOL/64c9d67043.png
Try getting rid of the () after level. Maybe that isn't a function.
It works great now!!! THANK YOU!!!!!!

Original thread: https://forums.rpgmakerweb.com/threads/set-variable-to-actor-level-question.52415/