How can I make the Level not start with 0 XP?

Hi

So I was wondering how could I make so, for example let’s sayyy, I’m currently at 200/300 XP and I earn 200 XP from a mob. How can I make it so i’m at 100/400 (because I earned 200) instead of it being 0/400 ?

Hopefully you understand what I mean. Thanks!

Calculate the remaining XP after a level up. You should do it recursively in case a package of XP is sufficient to level up multiple times.

local xpRequired = { --table of max xp according to level. index represents level
	300;
	400;
};
local lvl, xp = 1, 200; --represents player's current stats

xp += 200; --represents an increase in xp

repeat
	local req = xpRequired[lvl];
	
	if xp >= req then
		xp -= req;
		lvl += 1;
	end
until xp < req;
2 Likes

It worked perfectly!
Thanks a lot!