Lots of problems:
currentXP isn't a reference to the player's current xp, it's just a number of the xp the player has when that line of code runs.
level is defined twice.
There is no wait in the while loop, so it could crash the game.
You don't do anything to reset the xp or increase max xp after you give the player another level, so you'll get infinite levels.
This should work
game.Players.PlayerAdded:connect(function(plr)
plr.StarterGear:WaitForChild("SaveFolder")
local spins = plr.StarterGear.SaveFolder.Spins
local level = plr.StarterGear.SaveFolder.Level
local maxXP = plr.StarterGear.SaveFolder.MaxXP
local currentXP = plr.StarterGear.SaveFolder.CurrentXP
currentXP.Changed:connect(function()
if currentXP.Value >= maxXP.Value then
currentXP.Value = currentXP.Value - maxXP.Value
level.Value = level.Value + 1
end
end)
end
end) |