Random stat earned during level up?

Say that your character has 4 (insert stat here) to start with. And then when that character levels up, it has a chance of earning a stat gain of 1, 2, or 3, or have a chance of not earning any stat gain. So basically a random stat gain. You could be lucky and get a good roll and earn 3 (insert stat here), or you could have bad luck and have no change to your (insert stat here) when your actor gets a level up.

Is this possible, if so, how? I'm okay with a script.
Mk, after tryna work this out for a while I think I know how to do this. (bear in mind that I'm a noob when it comes to rpg maker so this method might not be perfect XD) So, to do this you gotta create a common event (unless you don't mind copy-pasting the same event over and over again) Let's just say, we'll call it 'Level up'. In this event, increase the actor's level by 1, Then create a control switch which I'll name 'Level up' too for convenience. Turn on the control. Your event page should look like this :https://i.imgur.com/179pGV9.jpg
Now, create another common event which I'll call 'stat add'. Set it's trigger to 'Autorun' and it's condition switch to 'Level up' Now create a variable by the name 'stat add'and set it's operand to 'random' (from 0-3). Now, create 4 conditional branches with that variable, corresponding to how much of the stat your actor has earned. Here's how it should look cuz' I suck at explaining :https://i.imgur.com/qVuFKrx.jpg
Turn off your 'level up' Control switch or otherwise the event will keep looping itself, So now whenever you need your character to gain a random stat, simply use a 'call common event' and call 'Level up'. If you have any questions please don't hesitate to ask, Like I said before. I REALLY suck at explaining XD (btw, feel free to replace 'EXP' with an other stat)
How will the common event know that a particular actor has just leveled up and so qualifies for a stat increase?
Once you call the level up event, It will automatically level up your actor. You can edit it so that it levels up more than one actor at once, or create more scripts like that one if you want to level up each of your party members individually.) Afterwards it will turn on the 'Level up' switch which will cause the stat event to autorun. Is this explanation better?
Okay, thanks!
Np! Glad I could help :3

Original thread: https://forums.rpgmakerweb.com/threads/random-stat-earned-during-level-up.88952/