Problem with leveling up system

So to start off, my leveling system works but it does have a very large downside. When the player gets given for example 9999 XP, and the required to level up is 400, it will give you only 1 level and it will reset your xp to 0. What i want is when you level up it takes the remaining xp and adds it to the new xp, so if the user gets given 9999 XP instead of level once and XP gets reset, he keeps leveling up until that 9999 XP runs out and he will have that much XP left, here is a video and the code:

		XP.Changed:Connect(function()	
			if XP.Value >= ((Level.Value * 1000) + math.random(250,500)) / 1.2 then
				Level.Value 	+= 1
				XP.Value = 0
			end						
		end)

Your not carrying over the remaining xp, try this

XP.Changed:Connect(function()
    local requiredXP = (Level.Value * 1000) + math.random(250, 500) 
    if XP.Value >= requiredXP then
        Level.Value += 1
        XP.Value = XP.Value - requiredXP
    end
end)

Thank you, and double thank you for the fast reply, also incase you were wondering why i needed this, i plan to host allot of events in my game that will reward large chunks of XP

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.