So I’ve reached the stage in my game where I want to be able to calculate how much exp they gained, so if its 3x the max exp it levels the player up 3 times and shows the remaining amount of exp until leveling up again.
I’m not sure if I explained that correctly, so I’ll try to give somewhat of an example as to what I’ve been doing which has been causing lag spikes if a player gains too much exp.
for i = 1,amount,1 do
local maxExp = lev*150 -- the max exp of each level
eeexp = eeexp + 1 -- i'm counting the exp + 1
if eeexp >= maxExp then -- each time the exp hits max it levels up and exp reverts back to 0
lev = lev + 1
eeexp = 0
end
end
if exp and level then
level.Value = lev
exp.Value = eeexp
end
I know there’s a way to calculate the level just by doing;
level = exp/maxexp
but I don’t understand how I am supposed to get the remaining exp in 1 single equation. I’m also unsure if the math above would even be a solution. I know it’s possible, and less lag spikey so I’m currently trying to do that. Does anyone know what I can do to make this equation happen?