Hello everyone! so im trying to make a leveling system that can take any exp amount and make them into exp.
so for example a player got 50k exp and the exp requirement for level up is 5k and the formula is (exp_req x level), so the player level must be 5.
here’s the code example :
local need = 5000
local exp = 50000
local level = 1
local current_exp = exp
local current_level = level
print(need*level, exp, level) -- 5000, 50000, 1
repeat
current_exp -= need * current_level
current_level += 1
until current_exp < (need * current_level)
print(need*current_level, current_exp, current_level) -- 25000, 0, 5
and since my project is a clicking simulator game the game can go infinitely, i need the code to get the level of the player exp just like the code example since if the player got op pets and high rebirth, the exp can be high and take much time to finished leveling up, and i need it to instant calculated instead of doing it inside a heartbeat.
if anyone know please help