How do I make it so that the remaining exp gets rolled over to the next level?
I know It has to do with me putting Exp.Value = 0 but I’m not sure what else to put there to make it rollover and not reset to 0.
local RequiredEXP = Instance.new("IntValue")
RequiredEXP.Name = "RequiredExp"
RequiredEXP.Value = Level.Value * 100
RequiredEXP.Parent = leaderboard
Exp.Changed:Connect(function(Changed)
if Exp.Value >= RequiredEXP.Value then
Exp.Value = 0
Level.Value += 1
RequiredEXP.Value = Level.Value * 100
end
local level = 1
local xp = 1502
local XPNeededToLevel = 100
function xpChanged()
if xp >= XPNeededToLevel then
local leftOverXP = xp - XPNeededToLevel
level += 1
xp = leftOverXP
print("Level:",level, "XP:",xp)
xpChanged() -- in case its over enough xp to level up twice
end
end
xpChanged()
Now I’m having another problem I don’t know whats causing it but each time I play the game I get a bunch of levels with this in the output. I dont have any parts that gives a lot of Exp for this to be happening
Maximum event re-entrancy depth exceeded for IntValue.Changed