My level system doesn't carry over XP if you get more than you need. If you need 1000 XP to level up, but get 1500 then it won't make the 500 count towards the next level. I was thinking maybe if the XP value is greater than what you need to level up it can store it as a value and then add the value to the player's XP after they level up? Not really sure how to do this though. Here's my level system:
XP.Changed:Connect(function() if XP.Value >= Level.Value * 20 then Stats.XP.Value = 0 Player.Character.Humanoid.Health = Player.Character.Humanoid.Health + 100000 Stats.Level.Value = Stats.Level.Value + 1 Stats.StatPoints.Value = Stats.StatPoints.Value + 3 Player.Character.UpperTorso.LevelUp:Play() local Particle = game.ReplicatedStorage.LevelParticle:Clone() Particle.Parent = Player.Character.UpperTorso Particle.delete.Disabled = false end end)
thanks for reading
Replace
Stats.XP.Value = 0
^This always sets the value XP to 0
with
Stats.XP.Value = Stats.XP.Value - (Level.Value * 20)
^This subtracts the level multiplied by 20 from XP
You can use modulo %
to get the remainder in division
local xp_per_level = 100 local total_xp = 230 local xp = total_xp % xp_per_level -- 30