Hi! Gdevelop community members, I have a problem with my resource bar

I named it “ExpBar” I want to use it as an Exp bar of player

I have an event to level up the player and reset the Exp bar to 0 with higher Exp requirement

The problem is when the Exp bar is almost full for example:

Resource bar is now 90/100 Then → The player + 25 Exp,

The expected result should be 90/100 → gain 25 Exp → Level up → new level with 15 / 100 or 15 / 1xx something

But my result is 90/100 → gain 25 Exp → Level up → Exp now 0 / 1xx

The question is how do I keep the remaining Exp from the exceed Exp when the bar is reset?

Hello, thananaza

I don’t know if there is a more simple solution (maybe just math and expressions), but I did something using a scene variable (because if you delete your instance of the Player you will lose the exp information and that’s why in my game I use scene variables for my player, but that is just a tip):

All exp will be add to your bar AND this variable. In the event with the full bar the logic of actions will be:

- Subtract from variable the max value of your full bar;
- Change the value of your bar with the value of the variable (if anything left it will add)
- Add +1 level

2 Likes

Thanks, Rasterisko for helping me again It works with no problem and thanks for the tip of moving exp into scene variable I have never thought of that before.