I've written this LevelUp script, but it doesn't work. It just doesn't set the player's level, despite the Experience being enough. I changed my Experience to 1500 to check if it worked, but I remained at level 1. What is the problem?
local xps = {0,3, 6, 10, 15, 20, 25, 30, 40, 50, 65, 80, 95, 110, 125, 140, 155, 180, 210, 250, 300, 350, 400, 450, 500, 575, 650, 725, 825, 1000}; function experience() Player = game.Players.LocalPlayer local xp = Player.Exp.Value for level = 1, #xps do --[[The square bracket gets a certain item out of a table. If it were xps[1] it would get the 1st item; xps[2] the second item, and so on. Starts at level one, and goes through all the xps associated with each level.]] if xp >= xps[level] * 100 then --If the player's xps is greater than the required amount, it levels them up. Player.leaderstats.Level.Value = level; end end Player.Character:WaitForChild("Humanoid").MaxHealth = 200 + 100 * Player.leaderstats.PlayerLevel.Value --Sets their health. If they have a higher level, they get more health. end game.Players.PlayerAdded:connect(experience) game.Players.LocalPlayer.Exp.Changed:connect(experience)